net.grelf.grip
Interface Image

All Known Subinterfaces:
Accumulator
All Known Implementing Classes:
AccumulatorDouble, AccumulatorInt, ImageDouble, ImageInt

public interface Image

For adding or averaging images or for holding them in a format that is not provided by java.awt.image.BufferedImage (eg, floating-point pixel values).
NB: The layout of the data is very important: bear in mind that every sub-array has an overhead of 12 bytes.
11.10.23: Changes made to reduce interdependencies:
1. void drawImage (net.grelf.grip.Imframe) becomes void drawImage (java.awt.image.BufferedImage)
2. void splitChannels (net.grelf.grip.Imframe) becomes Image [] splitChannels ()
3. displayAs3x16bitImage () has been obsolete for some time and has been removed completely.
11.11.3: Refactored as base interface for Accumulator by removing the warp/shift methods. This is a further step towards reducing interdependencies.


Method Summary
 void add(java.awt.image.BufferedImage bim)
          Add pixel values from bim into the data array.
 void add(java.awt.image.BufferedImage bim, double dx, double dy)
          Add pixel values from bim into the data array, offset by vector (dx, dy).
 void add(java.awt.image.BufferedImage bim, int dx, int dy)
          Add pixel values from bim into the data array, offset by vector (dx, dy).
 void add(Image other)
          Add pixel values from the other Image into the current data array.
 void applyCurve(RangeInt currentRange, java.util.List<java.awt.Point> points, java.awt.image.BufferedImage bim)
          Apply a look-up curve to transform data pixels into BufferedImage pixels.
 void autoCrop()
          Automatically remove any rectangular margin of black (0, 0, 0) pixels from the image, thereby cropping it.
 void autoStretch(boolean allChannelsSame)
          Stretch the contrast in the image so the full range of levels is used.
 void autoStretch(boolean allChannelsSame, java.awt.Point topLeft, java.awt.Point bottomRight)
          Stretch the contrast in the image so the full range of levels is used.
 byte[][] autoThreshold()
          Threshold automatically.
 void averageVertically()
          Replace every pixel of every vertical line in the image by the average of the levels along the line.
 void averageVertically(int yMin, int yMax)
          Replace every pixel of every vertical line in the image by the average of the levels along the line, within two y coordinate limits.
 Image clone()
           
 void convertToMonochrome()
          Reduce the number of bands from 3 to 1, converting RGB to monochrome, using 0.325 x red + 0.5 * green + 0.175 * blue.
 void convertToMonochrome(double... f)
          Reduce the number of bands to 1, combining channels, using sum_i (f[i]/I x px[i]), where I = sum_i (f[i]).
 void crop(java.awt.Point pt1, java.awt.Point pt2)
          Crop the Image by a rectangle defined by the diagonally opposite points.
 void divide(int n)
          Divide all pixel values (in all bands) in the Image by n.
 void drawImage(java.awt.image.BufferedImage bim)
          Convert the Image data into a BufferedImage, by drawing them into the image displayed in an ImFrame.
 void fit(int width, int height)
          Scale the image so it fits into the given width and height (in pixels), without changing its proportions.
 void flipHorizontal()
          Flip the image horizontally.
 void flipVertical()
          Flip the image vertically.
 int getBitsPerChannel()
          Get the number of bits per channel.
 RangeInt[] getChannelRanges()
          Find the range of values in each channel, as pairs of int values.
 RangeDouble[] getChannelRangesDouble()
          Find the range of values in each channel, as pairs of double values.
 int getHeight()
          Get the height, in pixels, of the Image.
 Metadata getMetadata()
          Get metadata associated with the image.
 int getNBands()
          Get the number of bands (channels) in the Image.
 RangeInt getOverallRange()
          Get overall range of values across all channels, as a pair of int values
 RangeDouble getOverallRangeDouble()
          Get overall range of values across all channels, as a pair of double values
 int[] getPixel(int x, int y)
          Get array of int pixel values for all bands at the given integer (x, y) position.
 double[] getPixelDouble(int x, int y)
          Get array of double pixel values for all bands at the given integer (x, y) position.
 double[] getPixelDoubleInterpolated(double x, double y)
          Get array of double pixel values for all bands at the given fractional (x, y) position.
 int[] getPixelInterpolated(double x, double y)
          Get array of int pixel values for all bands at the given fractional (x, y) position.
 RangeInt getRange()
          Get the minimum and maximum values occurring across all channels, as a pair of int values.
 RangeDouble getRangeDouble()
          Get the minimum and maximum values occurring across all channels, as a pair of double values.
 int getWidth()
          Get the width, in pixels, of the Image.
 Image gnomonicProjection(int focalLength)
          Project from sphere to plane.
 Image inverseGnomonicProjection(int focalLength)
          Project from plane to sphere.
 void invert()
          Invert the colour at every pixel in the image.
 void meanFilter(int halfWidth, javax.swing.ProgressMonitor monitor)
          Replace every pixel in the image by the mean value of its n x n neighbourhood, where n = 2.halfWidth + 1.
 void medianFilter(int halfWidth, javax.swing.ProgressMonitor monitor)
          Replace every pixel in the image by the median value of its n x n neighbourhood, where n = 2.halfWidth + 1.
 void multiply(double f)
          Multiply all pixel values (in all bands) in the Image by factor f, truncating the result if pixels contain integer values.
 void nearestExtremeFilter(int halfWidth, javax.swing.ProgressMonitor monitor)
          Replace every pixel in the image by the nearest of the max and min of its n x n neighbourhood, where n = 2.halfWidth + 1.
 void neutraliseBackground()
          Equate the histogram modes of all channels by stretching from the overall maximum value.
 void rankFilter(int halfWidth, javax.swing.ProgressMonitor monitor)
          Replace every pixel in the image by its rank in its n x n neighbourhood, where n = 2.halfWidth + 1.
 void reapplyColour(Image intensityAcc, Image colourAcc)
          For combining a monochrome intensity image with a multi-band colour information image, the 2 images having been created by ImProcess.splitIntensity ().
 Image rotate(double angleDegs)
          Rotate the image anticlockwise by the given angle (in degrees).
 void save(java.lang.String filePath)
          Save on disc: slower version, has to work out the range of values occurring in the Image.
 void save(java.lang.String filePath, RangeDouble range)
          Save on disc: faster version if the range of values occurring in the Image is already known.
 void save(java.lang.String filePath, RangeInt range)
          Save on disc: faster version if the range of values occurring in the Image is already known.
 void saveAsFITS(java.lang.String filePath)
           
 Image scale(double factor, boolean interpolating)
          Scale the image in x and y by the given factor
 void scale(RangeDouble[] currentChannelRanges, java.awt.image.BufferedImage bim)
          Offset and scale all values to fit into the supplied BufferdImage.
 void scale(RangeDouble[] currentChannelRanges, RangeDouble[] targetChannelRanges)
          Offset and scale all values to fit in the given target ranges.
 void scale(RangeInt[] currentChannelRanges, java.awt.image.BufferedImage bim)
          Offset and scale all values to fit into the supplied BufferedImage.
 void scale(RangeInt[] currentChannelRanges, RangeInt[] targetChannelRanges)
          Offset and scale all values to fit in the given target ranges.
 void set(java.awt.image.BufferedImage bim)
          Set pixel values from bim into the data array.
 void setMetadata(Metadata theData)
          Associate metadata with the image.
 void setPixel(int x, int y, int[] px)
          Does nothing if (x, y) is outside the image.
 void setPixel(int x, int y, int band, int px)
          Set value into a single band of a pixel without changing the other bands.
 void setPixelDouble(int x, int y, double[] px)
          Does nothing if (x, y) is outside the image.
 void setPixelDouble(int x, int y, int band, double px)
          Set value into a single band of a pixel without changing the other bands.
 Image[] splitChannels()
          Convert image to any array of monochrome images.
 void subtract(java.awt.image.BufferedImage bim)
          Subtract pixel values of bim from the data array.
 byte[][] threshold(Threshold thresh)
          Threshold the image to detect pixels in the range(s) specified by the given threshold.
 java.lang.String toString()
           
 Image translate(int dx, int dy)
          Displace the image content by the given offset vector.
 void varianceFilter(int halfWidth, javax.swing.ProgressMonitor monitor)
          Replace every pixel in the image by the variance of its n x n neighbourhood, where n = 2.halfWidth + 1.
 

Method Detail

add

void add(Image other)
         throws IncompatibleImageException
Add pixel values from the other Image into the current data array. If other is larger than the data then the rectangle starting at the top left corner of other which overlaps the data will be used.

Throws:
IncompatibleImageException

add

void add(java.awt.image.BufferedImage bim)
         throws IncompatibleImageException
Add pixel values from bim into the data array. If bim is larger than the data then the rectangle starting at the top left corner of bim which overlaps the data will be used.

Throws:
IncompatibleImageException

add

void add(java.awt.image.BufferedImage bim,
         int dx,
         int dy)
         throws IncompatibleImageException
Add pixel values from bim into the data array, offset by vector (dx, dy). Only those pixels of the offset bim which overlap the data are used. using integer coordinates, this version is fast but does not interpolate from the source image.
10.10.22: Major bug fixed.

Throws:
IncompatibleImageException

add

void add(java.awt.image.BufferedImage bim,
         double dx,
         double dy)
         throws IncompatibleImageException
Add pixel values from bim into the data array, offset by vector (dx, dy). Only those pixels of the offset bim which overlap the data are used. Using double coordinates, this version is slower but does interpolate from the source image.
10.10.22: Major bug fixed.

Throws:
IncompatibleImageException

applyCurve

void applyCurve(RangeInt currentRange,
                java.util.List<java.awt.Point> points,
                java.awt.image.BufferedImage bim)
                throws IncompatibleImageException
Apply a look-up curve to transform data pixels into BufferedImage pixels. The curve is a set of points with x and y ranges of 0..255 but the data (x-axis) has 32-bit range and the target image (y-axis) may have any number of bits per channel. The data and image must have the same number of channels, otherwise an IncompatibleImageException is thrown.

Throws:
IncompatibleImageException

autoCrop

void autoCrop()
Automatically remove any rectangular margin of black (0, 0, 0) pixels from the image, thereby cropping it. Potentially replaces the data array inside this Image by a new smaller one.


autoStretch

void autoStretch(boolean allChannelsSame)
Stretch the contrast in the image so the full range of levels is used.


autoStretch

void autoStretch(boolean allChannelsSame,
                 java.awt.Point topLeft,
                 java.awt.Point bottomRight)
Stretch the contrast in the image so the full range of levels is used. This version only changes pixels in the rectangle defined by the two points as diagonal. The upper level of the data will not change but if the lower level was not zero a linear rescaling will make it so.


autoThreshold

byte[][] autoThreshold()
Threshold automatically. First gets a histogram and finds the channel means. Sets the threshold for each channel: if the mean is lower than half-way up the brightness range the background is assumed to be dark so the threshold goes from half-way up to the top. Otherwise the background is assumed to be bright so the threshold goes from 0 to half-way. Then does the thresholding to set a mask in the GlassPane, suitable for blob detection.
Not for segmenting stars: use StarSegmenter class instead.


averageVertically

void averageVertically()
Replace every pixel of every vertical line in the image by the average of the levels along the line. This is for analysing profiles (particularly for spectroscopy). Rotate and crop the image appropriately before using this.


averageVertically

void averageVertically(int yMin,
                       int yMax)
Replace every pixel of every vertical line in the image by the average of the levels along the line, within two y coordinate limits. This is for analysing profiles (particularly for spectroscopy). Rotate and crop the image appropriately before using this.


clone

Image clone()

convertToMonochrome

void convertToMonochrome()
Reduce the number of bands from 3 to 1, converting RGB to monochrome, using 0.325 x red + 0.5 * green + 0.175 * blue. Replaces the data array inside this Image by a new smaller one.


convertToMonochrome

void convertToMonochrome(double... f)
Reduce the number of bands to 1, combining channels, using sum_i (f[i]/I x px[i]), where I = sum_i (f[i]). Replaces the data array inside this Image by a new smaller one.


crop

void crop(java.awt.Point pt1,
          java.awt.Point pt2)
Crop the Image by a rectangle defined by the diagonally opposite points. Does not assume pt1 is above or to the left of pt2. Replaces the data array inside this Image by a new smaller one.


divide

void divide(int n)
Divide all pixel values (in all bands) in the Image by n.


drawImage

void drawImage(java.awt.image.BufferedImage bim)
Convert the Image data into a BufferedImage, by drawing them into the image displayed in an ImFrame. This does not throw an exception if the Image is not the same size as the ImFrame, on the grounds that the user will see the result. Assumes that the bit depth of the BufferedImage is enough to hold the maximum value in the Image. If that is not the case pixels will overflow, so consider using ImCurveDialogue.askCurve (imf, accum) instead, to allow the user to scale the data into the required range. 11.10.23: Changed parameter from ImFrame to BufferedImage, to reduce dependencies.


fit

void fit(int width,
         int height)
Scale the image so it fits into the given width and height (in pixels), without changing its proportions. Replaces the data array inside this Image by a new smaller one.


flipHorizontal

void flipHorizontal()
Flip the image horizontally.


flipVertical

void flipVertical()
Flip the image vertically.


getBitsPerChannel

int getBitsPerChannel()
Get the number of bits per channel.


getChannelRanges

RangeInt[] getChannelRanges()
Find the range of values in each channel, as pairs of int values.


getChannelRangesDouble

RangeDouble[] getChannelRangesDouble()
Find the range of values in each channel, as pairs of double values.


getHeight

int getHeight()
Get the height, in pixels, of the Image.


getMetadata

Metadata getMetadata()
Get metadata associated with the image. Null if none.


getNBands

int getNBands()
Get the number of bands (channels) in the Image.


getOverallRange

RangeInt getOverallRange()
Get overall range of values across all channels, as a pair of int values


getOverallRangeDouble

RangeDouble getOverallRangeDouble()
Get overall range of values across all channels, as a pair of double values


getPixel

int[] getPixel(int x,
               int y)
Get array of int pixel values for all bands at the given integer (x, y) position. Returns all zeroes if the position is outside the data array.


getPixelDouble

double[] getPixelDouble(int x,
                        int y)
Get array of double pixel values for all bands at the given integer (x, y) position. Returns all zeroes if the position is outside the data array.


getPixelDoubleInterpolated

double[] getPixelDoubleInterpolated(double x,
                                    double y)
Get array of double pixel values for all bands at the given fractional (x, y) position. Returns all zeroes if the position is outside the data array.


getPixelInterpolated

int[] getPixelInterpolated(double x,
                           double y)
Get array of int pixel values for all bands at the given fractional (x, y) position. Returns all zeroes if the position is outside the data array.


getRange

RangeInt getRange()
Get the minimum and maximum values occurring across all channels, as a pair of int values.


getRangeDouble

RangeDouble getRangeDouble()
Get the minimum and maximum values occurring across all channels, as a pair of double values.


getWidth

int getWidth()
Get the width, in pixels, of the Image.


gnomonicProjection

Image gnomonicProjection(int focalLength)
Project from sphere to plane.


inverseGnomonicProjection

Image inverseGnomonicProjection(int focalLength)
Project from plane to sphere.


invert

void invert()
Invert the colour at every pixel in the image.


meanFilter

void meanFilter(int halfWidth,
                javax.swing.ProgressMonitor monitor)
Replace every pixel in the image by the mean value of its n x n neighbourhood, where n = 2.halfWidth + 1.


medianFilter

void medianFilter(int halfWidth,
                  javax.swing.ProgressMonitor monitor)
Replace every pixel in the image by the median value of its n x n neighbourhood, where n = 2.halfWidth + 1.


multiply

void multiply(double f)
Multiply all pixel values (in all bands) in the Image by factor f, truncating the result if pixels contain integer values.


nearestExtremeFilter

void nearestExtremeFilter(int halfWidth,
                          javax.swing.ProgressMonitor monitor)
Replace every pixel in the image by the nearest of the max and min of its n x n neighbourhood, where n = 2.halfWidth + 1.


neutraliseBackground

void neutraliseBackground()
Equate the histogram modes of all channels by stretching from the overall maximum value.


rankFilter

void rankFilter(int halfWidth,
                javax.swing.ProgressMonitor monitor)
Replace every pixel in the image by its rank in its n x n neighbourhood, where n = 2.halfWidth + 1. The rank is scaled up so that its possible values span the grey level range of the image. Each channel is treated independently.


reapplyColour

void reapplyColour(Image intensityAcc,
                   Image colourAcc)
For combining a monochrome intensity image with a multi-band colour information image, the 2 images having been created by ImProcess.splitIntensity (). The result fills the current Image, overwriting any previous contents.


rotate

Image rotate(double angleDegs)
Rotate the image anticlockwise by the given angle (in degrees).


save

void save(java.lang.String filePath)
Save on disc: slower version, has to work out the range of values occurring in the Image.


save

void save(java.lang.String filePath,
          RangeInt range)
Save on disc: faster version if the range of values occurring in the Image is already known.


save

void save(java.lang.String filePath,
          RangeDouble range)
Save on disc: faster version if the range of values occurring in the Image is already known.


saveAsFITS

void saveAsFITS(java.lang.String filePath)

scale

Image scale(double factor,
            boolean interpolating)
Scale the image in x and y by the given factor


scale

void scale(RangeInt[] currentChannelRanges,
           RangeInt[] targetChannelRanges)
Offset and scale all values to fit in the given target ranges. Both input arrays must have the same number of dimensions, equal to the number of channels.


scale

void scale(RangeDouble[] currentChannelRanges,
           RangeDouble[] targetChannelRanges)
Offset and scale all values to fit in the given target ranges. Both input arrays must have the same number of dimensions, equal to the number of channels.


scale

void scale(RangeInt[] currentChannelRanges,
           java.awt.image.BufferedImage bim)
           throws IncompatibleImageException
Offset and scale all values to fit into the supplied BufferedImage. The input array must have the same number of dimensions as the number of channels. The BufferedImage must have the same number of channels as this Image, otherwise an IncompatibleImageException is thrown.

Throws:
IncompatibleImageException

scale

void scale(RangeDouble[] currentChannelRanges,
           java.awt.image.BufferedImage bim)
           throws IncompatibleImageException
Offset and scale all values to fit into the supplied BufferdImage. The input array must have the same number of dimensions as the number of channels. The BufferedImage must have the same number of channels as this Image, otherwise an IncompatibleImageException is thrown.

Throws:
IncompatibleImageException

set

void set(java.awt.image.BufferedImage bim)
         throws IncompatibleImageException
Set pixel values from bim into the data array. If bim is larger than the data then the rectangle starting at the top left corner of bim which overlaps the data will be used.

Throws:
IncompatibleImageException

setMetadata

void setMetadata(Metadata theData)
Associate metadata with the image.


setPixel

void setPixel(int x,
              int y,
              int[] px)
Does nothing if (x, y) is outside the image.


setPixel

void setPixel(int x,
              int y,
              int band,
              int px)
Set value into a single band of a pixel without changing the other bands. Does nothing if (x, y) is outside the image.


setPixelDouble

void setPixelDouble(int x,
                    int y,
                    double[] px)
Does nothing if (x, y) is outside the image.


setPixelDouble

void setPixelDouble(int x,
                    int y,
                    int band,
                    double px)
Set value into a single band of a pixel without changing the other bands. Does nothing if (x, y) is outside the image.


splitChannels

Image[] splitChannels()
Convert image to any array of monochrome images. 11.10.23: ImFrame parameter removed and return type added, to reduce dependencies.


subtract

void subtract(java.awt.image.BufferedImage bim)
              throws IncompatibleImageException
Subtract pixel values of bim from the data array. If bim is larger than the data then the rectangle starting at the top left corner of bim which overlaps the data will be used.

Throws:
IncompatibleImageException

threshold

byte[][] threshold(Threshold thresh)
Threshold the image to detect pixels in the range(s) specified by the given threshold. Return a binary mask (values BlobMask.MASK_CLEAR or BlobMask.MASK_SET), suitable for setting into GlassPane. The image may have any number of bands.


translate

Image translate(int dx,
                int dy)
Displace the image content by the given offset vector. Image size is unchanged. Margins exposed by the shift are filled with zeroes. Portions of the image shifted off the edge are lost. Shifting an image by a very small amount and then subtracting it from itself (eg, as previously cloned from the image menu) is a way of detecting edges in the direction of the offset.


toString

java.lang.String toString()
Overrides:
toString in class java.lang.Object

varianceFilter

void varianceFilter(int halfWidth,
                    javax.swing.ProgressMonitor monitor)
Replace every pixel in the image by the variance of its n x n neighbourhood, where n = 2.halfWidth + 1.