net.grelf.grip
Class ImageInt

java.lang.Object
  extended by net.grelf.grip.ImageBase
      extended by net.grelf.grip.ImageInt
All Implemented Interfaces:
java.lang.Cloneable, Image
Direct Known Subclasses:
AccumulatorInt

public class ImageInt
extends ImageBase
implements Image, java.lang.Cloneable

For holding and processing images having 32 bits (integer) per pixel per channel. Originally used for adding 16-bit images, to prevent overflow but that is now done by the sub-class AccumulatorInt.

This needs a lot of memory of course: width x height x (12 + 4n) bytes for n-channel images.
This Image is used as an alternative to BufferedImage for holding 32-bits-per-channel (integer) images. Its behaviour differs from BufferedImages in that the maximum level available is not automatically increased to 2 to the power 32. A 16-bit BufferedImage would always be considered to have a maximum level of 65535 but the maximum level of an Accumulator is the maximum level actually reached in the data (across all channels). The range of values held must be updated by every operation that modifies the data, so it is then available as getRange () without rescanning the image. A rescan can always be done, by getOverallRange () or getChannelRanges (), but that can be time consuming.

Whereas a BufferedImage would be processed by static methods in class ImProcess, ImageInts have all such methods as instance methods.

The data can be saved on disc and reloaded in FITS format. GRIP has its own simple format (.accum files) which has really been made obsolete by the FITS capability but it is still available for backwards compatibility. The .accum format comprises a text header followed by binary pixel data. The header is Java 2-bytes-per-character text strings, each preceded by an int containing the number of characters in the string. Each string except the first contains an equals sign (=) after which are the digits of a value. There are no line end characters or other formatting. The strings are (UTF-8 encoding):

GRIP v...
width(px)=...
height(px)=...
channels=...
bitsPerChannel=32
min=...
max=...

where the first string contains the GRIP version number and min and max show the overall range of values occurring (across all channels).

The binary pixel data are stored as int values, in the usual Java big-endian format, in this order:

for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
for (int b = 0; b < nBands; b++)
{
dos.writeInt (accum [x][y][b]); // dos is a java.io.DataOutputStream
}
}
}


Field Summary
protected  int[][] data
           
 
Constructor Summary
ImageInt(java.awt.image.BufferedImage bim)
          Use the BufferedImage to set the width, height and number of bands (channels) in this Image.
ImageInt(int width, int height, int nBands)
          Creates image without setting any pixels.
ImageInt(int width, int height, int nBands, boolean fillWithZeroes)
          Creates image with pixels optionally set to zero.
ImageInt(java.lang.String filePath)
          Reload an accumulator that has previously been saved on disc by GRIP.
 
Method Summary
 void add(java.awt.image.BufferedImage bim)
          Add pixel values from bim into the accumulator array.
 void add(java.awt.image.BufferedImage bim, double dx, double dy)
          Add pixel values from bim into the accumulator array, offset by vector (dx, dy).
 void add(java.awt.image.BufferedImage bim, int dx, int dy)
          Add pixel values from bim into the accumulator array, offset by vector (dx, dy).
 void add(Image other)
          Add pixel values from the other Image into the current data array.
 void add(ImageInt other)
          Add pixel values from another accumulator into the accumulator array.
 void add(ImageInt other, double f1, double f2)
          Add pixel values from another accumulator into the accumulator array, taking fraction f1 of the values in the current accumulator and f2 of those in the other.
 void applyCurve(RangeInt currentRange, java.util.List<java.awt.Point> points, java.awt.image.BufferedImage bim)
          Apply a look-up curve to transform accumulator pixels into BufferedImage pixels or, if the BufferedImage is null, back into the accumulator.
 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.
protected  void checkCompatibility(java.awt.image.BufferedImage bim)
           
 Image clone()
           
 java.awt.image.BufferedImage convertTo16BitImage()
           
 ImageDouble convertToAccumulatorDouble()
          Convert to an AccumulatorDouble containing the same values.
 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]), wher * I = sum_i (f[i]).
 void correctBackground()
          Level the background of the image by dividing the image into n x n cells and using the modal values of the histogram in every cell.
 void crop(java.awt.Point pt1, java.awt.Point pt2)
          Crop the accumulator by a rectangle defined by the diagonally opposite points.
 void divide(int n)
          Divide all pixel values (in all bands) in the accumulator by n.
 void divideByFlatField(ImageInt other)
          Divide this accumulator by other accumulator (flat field), pixel by pixel.
 void drawImage(java.awt.image.BufferedImage bim)
          Convert the accumulator data into a BufferedImage, by drawing it into the image displayed in an ImFrame.
 void drawRim(int width, java.awt.Color colour)
          Draw a rim around the image, of the given width and colour
 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; always returns 32.
 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.
 int[] getHorizontalSamples(int x0, int y, int band, int n)
           
 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.
 RangeDouble getRangeDouble()
          Get the minimum and maximum values occurring, across all channels.
 int[] getVerticalSamples(int x, int y0, int band, int n)
           
 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.
static boolean isAccumFile(java.lang.String path)
          Read the start of a file to find out whether it is a saved Accumulator.
 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 accumulator by factor f, truncating the result if pixels contain integer values.
 void multiply(ImageInt other)
           
 void multiply(ImageInt other, double f1, double f2)
          Multiply fraction f1 of this accumulator by f2 of the other.
 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 modes in the histogram by stretching downwards from maxLevel.
 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 accumulator.
 void save(java.lang.String filePath, RangeDouble range)
          Save on disc: faster version if the range of values occurring in the accumulator is already known.
 void save(java.lang.String filePath, RangeInt range)
          Save on disc: faster version if the range of values occurring in the accumulator 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)
          Deprecated. 
 void scale(RangeDouble[] currentChannelRanges, RangeDouble[] targetChannelRanges)
          Deprecated. 
 void scale(RangeInt[] currentChannelRanges, java.awt.image.BufferedImage bim)
          Deprecated. 
 void scale(RangeInt[] currentChannelRanges, RangeInt[] targetChannelRanges)
          Deprecated. 
 void set(java.awt.image.BufferedImage bim)
          Set pixel values from bim into the accumulator 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.
protected  void setRange(RangeInt range)
           
 Image[] splitChannels()
          Convert image to any array of monochrome images.
 void subtract(java.awt.image.BufferedImage bim)
          Subtract pixel values of bim from the accumulator array.
 void subtract(ImageInt other)
          Subtract other from this, pixel by pixel, the result being about the half-way brightness level so that both negative and positive results can be seen.
 void subtractToZero(ImageInt other)
          Subtract other from this, pixel by pixel, negative results being cut off at zero.
 byte[][] threshold(Threshold thresh)
          Threshold the image to detect pixels in the range(s) specified by the given threshold.
 java.lang.String toString()
          Get a simple description : wd x ht x channels
 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.
 
Methods inherited from class net.grelf.grip.ImageBase
padTo, padTo, rJustified20
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

data

protected int[][] data
Constructor Detail

ImageInt

public ImageInt(int width,
                int height,
                int nBands)
Creates image without setting any pixels.


ImageInt

public ImageInt(int width,
                int height,
                int nBands,
                boolean fillWithZeroes)
Creates image with pixels optionally set to zero.


ImageInt

public ImageInt(java.awt.image.BufferedImage bim)
         throws IncompatibleImageException
Use the BufferedImage to set the width, height and number of bands (channels) in this Image. Populate the pixel values in the image data array from the BufferedImage also.

Throws:
IncompatibleImageException

ImageInt

public ImageInt(java.lang.String filePath)
Reload an accumulator that has previously been saved on disc by GRIP.

Method Detail

getWidth

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

Specified by:
getWidth in interface Image

getHeight

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

Specified by:
getHeight in interface Image

getNBands

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

Specified by:
getNBands in interface Image

getBitsPerChannel

public int getBitsPerChannel()
Get the number of bits per channel; always returns 32.

Specified by:
getBitsPerChannel in interface Image

getMetadata

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

Specified by:
getMetadata in interface Image

setMetadata

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

Specified by:
setMetadata in interface Image

getRange

public RangeInt getRange()
Get the minimum and maximum values occurring, across all channels. This range is updated by all operations that might change it, so it is not necessary to rescan the whole image data array to redetermine it.

Specified by:
getRange in interface Image

setRange

protected void setRange(RangeInt range)

getRangeDouble

public RangeDouble getRangeDouble()
Get the minimum and maximum values occurring, across all channels. Does not rescan the image.

Specified by:
getRangeDouble in interface Image

getOverallRange

public RangeInt getOverallRange()
Get overall range of values across all channels, as a pair of int values. Unlike getRange () this does scan the whole image data array to reset the extremes.

Specified by:
getOverallRange in interface Image

getOverallRangeDouble

public RangeDouble getOverallRangeDouble()
Get overall range of values across all channels, as a pair of double values. This does scan the entire image data array.

Specified by:
getOverallRangeDouble in interface Image

getChannelRanges

public RangeInt[] getChannelRanges()
Find the range of values in each channel, as pairs of int values. This does scan the entire image data array.

Specified by:
getChannelRanges in interface Image

getChannelRangesDouble

public RangeDouble[] getChannelRangesDouble()
Find the range of values in each channel, as pairs of double values. This does scan the entire image data array.

Specified by:
getChannelRangesDouble in interface Image

checkCompatibility

protected void checkCompatibility(java.awt.image.BufferedImage bim)
                           throws IncompatibleImageException
Throws:
IncompatibleImageException

add

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

Specified by:
add in interface Image
Throws:
IncompatibleImageException

add

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

Specified by:
add in interface Image
Throws:
IncompatibleImageException

add

public void add(ImageInt other)
         throws IncompatibleImageException
Add pixel values from another accumulator into the accumulator array. If the other accumulator is larger than this one then the rectangle starting at the top left corner which overlaps will be used.

Throws:
IncompatibleImageException

add

public void add(ImageInt other,
                double f1,
                double f2)
         throws IncompatibleImageException
Add pixel values from another accumulator into the accumulator array, taking fraction f1 of the values in the current accumulator and f2 of those in the other. If the other accumulator is larger than this one then the rectangle starting at the top left corner which overlaps will be used.

Throws:
IncompatibleImageException

add

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

Specified by:
add in interface Image
Throws:
IncompatibleImageException

add

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

Specified by:
add in interface Image
Throws:
IncompatibleImageException

applyCurve

public 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 accumulator pixels into BufferedImage pixels or, if the BufferedImage is null, back into the accumulator. The curve is a set of points with x and y ranges of 0..255 but the accumulator (x-axis) has 32-bit range and the target image (y-axis) may have any number of bits per channel. The accumulator and image must have the same number of channels, otherwise an IncompatibleImageException is thrown.

Specified by:
applyCurve in interface Image
Throws:
IncompatibleImageException

autoCrop

public 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 accumulator by a new smaller one.

Specified by:
autoCrop in interface Image

autoStretch

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

Specified by:
autoStretch in interface Image

autoStretch

public 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.

Specified by:
autoStretch in interface Image

autoThreshold

public 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.

Specified by:
autoThreshold in interface Image

averageVertically

public 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.

Specified by:
averageVertically in interface Image

averageVertically

public 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.

Specified by:
averageVertically in interface Image

clone

public Image clone()
Specified by:
clone in interface Image
Overrides:
clone in class java.lang.Object

convertTo16BitImage

public java.awt.image.BufferedImage convertTo16BitImage()

convertToAccumulatorDouble

public ImageDouble convertToAccumulatorDouble()
Convert to an AccumulatorDouble containing the same values.


convertToMonochrome

public 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 accumulator by a new smaller one.

Specified by:
convertToMonochrome in interface Image

convertToMonochrome

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

Specified by:
convertToMonochrome in interface Image

correctBackground

public void correctBackground()
Level the background of the image by dividing the image into n x n cells and using the modal values of the histogram in every cell. n is set in the Config.


crop

public void crop(java.awt.Point pt1,
                 java.awt.Point pt2)
Crop the accumulator 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 accumulator by a new smaller one.

Specified by:
crop in interface Image

drawRim

public void drawRim(int width,
                    java.awt.Color colour)
Draw a rim around the image, of the given width and colour


fit

public 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 accumulator by a new smaller one.

Specified by:
fit in interface Image

flipHorizontal

public void flipHorizontal()
Flip the image horizontally.

Specified by:
flipHorizontal in interface Image

flipVertical

public void flipVertical()
Flip the image vertically.

Specified by:
flipVertical in interface Image

divide

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

Specified by:
divide in interface Image

divideByFlatField

public void divideByFlatField(ImageInt other)
Divide this accumulator by other accumulator (flat field), pixel by pixel.


drawImage

public void drawImage(java.awt.image.BufferedImage bim)
Convert the accumulator data into a BufferedImage, by drawing it into the image displayed in an ImFrame. This does not throw an exception if the accumulator 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 Accumulator. 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.

Specified by:
drawImage in interface Image

getPixel

public 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 accumulator array.

Specified by:
getPixel in interface Image

getPixelDouble

public 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 accumulator array.

Specified by:
getPixelDouble in interface Image

getPixelInterpolated

public 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 accumulator array.

Specified by:
getPixelInterpolated in interface Image

getPixelDoubleInterpolated

public 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 accumulator array.

Specified by:
getPixelDoubleInterpolated in interface Image

getHorizontalSamples

public int[] getHorizontalSamples(int x0,
                                  int y,
                                  int band,
                                  int n)

getVerticalSamples

public int[] getVerticalSamples(int x,
                                int y0,
                                int band,
                                int n)

gnomonicProjection

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

Specified by:
gnomonicProjection in interface Image

inverseGnomonicProjection

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

Specified by:
inverseGnomonicProjection in interface Image

invert

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

Specified by:
invert in interface Image

isAccumFile

public static boolean isAccumFile(java.lang.String path)
Read the start of a file to find out whether it is a saved Accumulator.


meanFilter

public 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.

Specified by:
meanFilter in interface Image

medianFilter

public 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.

Specified by:
medianFilter in interface Image

multiply

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

Specified by:
multiply in interface Image

multiply

public void multiply(ImageInt other)

multiply

public void multiply(ImageInt other,
                     double f1,
                     double f2)
Multiply fraction f1 of this accumulator by f2 of the other.


nearestExtremeFilter

public 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.

Specified by:
nearestExtremeFilter in interface Image

neutraliseBackground

public void neutraliseBackground()
Equate the modes in the histogram by stretching downwards from maxLevel.

Specified by:
neutraliseBackground in interface Image

rankFilter

public 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.

Specified by:
rankFilter in interface Image

reapplyColour

public 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 Accumulator, overwriting any previous contents. This enables GRIP to implement the colour preservation scheme described at http://www.allthesky.com/articles/colorpreserve.html

Specified by:
reapplyColour in interface Image

rotate

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

Specified by:
rotate in interface Image

save

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

Specified by:
save in interface Image

save

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

Specified by:
save in interface Image

save

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

Specified by:
save in interface Image

saveAsFITS

public void saveAsFITS(java.lang.String filePath)
Specified by:
saveAsFITS in interface Image

scale

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

Specified by:
scale in interface Image

scale

@Deprecated
public void scale(RangeInt[] currentChannelRanges,
                             RangeInt[] targetChannelRanges)
Deprecated. 

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.

Specified by:
scale in interface Image

scale

@Deprecated
public void scale(RangeInt[] currentChannelRanges,
                             java.awt.image.BufferedImage bim)
           throws IncompatibleImageException
Deprecated. 

Offset and scale all values to fit into the supplied image. The input array must have the same number of dimensions as the number of channels. The image must have the same number of channels as the accumulator, otherwise an IncompatibleImageException is thrown.

Specified by:
scale in interface Image
Throws:
IncompatibleImageException

scale

@Deprecated
public void scale(RangeDouble[] currentChannelRanges,
                             RangeDouble[] targetChannelRanges)
Deprecated. 

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.

Specified by:
scale in interface Image

scale

@Deprecated
public void scale(RangeDouble[] currentChannelRanges,
                             java.awt.image.BufferedImage bim)
           throws IncompatibleImageException
Deprecated. 

Offset and scale all values to fit into the supplied image. The input array must have the same number of dimensions as the number of channels. The image must have the same number of channels as the accumulator, otherwise an IncompatibleImageException is thrown.

Specified by:
scale in interface Image
Throws:
IncompatibleImageException

set

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

Specified by:
set in interface Image
Throws:
IncompatibleImageException

setPixel

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

Specified by:
setPixel in interface Image

setPixel

public 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.

Specified by:
setPixel in interface Image

setPixelDouble

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

Specified by:
setPixelDouble in interface Image

setPixelDouble

public 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. Simply casts double value to int.

Specified by:
setPixelDouble in interface Image

splitChannels

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

Specified by:
splitChannels in interface Image

subtract

public void subtract(ImageInt other)
Subtract other from this, pixel by pixel, the result being about the half-way brightness level so that both negative and positive results can be seen.


subtract

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

Specified by:
subtract in interface Image
Throws:
IncompatibleImageException

subtractToZero

public void subtractToZero(ImageInt other)
Subtract other from this, pixel by pixel, negative results being cut off at zero.


threshold

public 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.

Specified by:
threshold in interface Image

toString

public java.lang.String toString()
Get a simple description : wd x ht x channels

Specified by:
toString in interface Image
Overrides:
toString in class java.lang.Object

translate

public 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.

Specified by:
translate in interface Image

varianceFilter

public 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.

Specified by:
varianceFilter in interface Image