uk.ac.ed.ph.signal
Class RealImage

java.lang.Object
  extended by javax.vecmath.Tuple2d
      extended by javax.vecmath.Point2d
          extended by uk.ac.ed.ph.signal.Grid2d
              extended by uk.ac.ed.ph.signal.Image
                  extended by uk.ac.ed.ph.signal.RealImage
All Implemented Interfaces:
Serializable, Cloneable

public class RealImage
extends Image

Class to read and maniulate real monochrone images held as doubles.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class uk.ac.ed.ph.signal.Image
data, statistics
 
Fields inherited from class uk.ac.ed.ph.signal.Grid2d
height, width
 
Fields inherited from class javax.vecmath.Tuple2d
x, y
 
Constructor Summary
RealImage(ComplexImage s)
          Constuctor to form a RealImage from a ComplexImage with default conversion flag
RealImage(ComplexImage s, int flag)
          Constuctor to form a RealImage from a ComplexImage with a conversion flag
RealImage(int w, int h)
          Construcor to form RealImage of specified size in real space with the pixel values defaulting to zero.
RealImage(RealDataArray dataArray)
          Constuctor to form a RealImage from a specifed RealDataArray
RealImage(RealImage s)
          Constrcuor to form new RealImage being a copy of the specified RealImage including the image data.
RealImage(RealImage s, boolean copydata)
          Constrcuor to form new RealImage being a copy of the specified RealImage.
 
Method Summary
 RealImage blankcopy()
          Method to forms a blacnk copy of the corrent RealImage with all parameters copyied, but the image data left blank.
 void calculateStatistics()
          Method to calcualte the statisticse, even if they are currently flagged as valid.
 RealImage clone()
          Methed to clone the current image, inclduing the data
 RealImage convolve(ImageFilterKernel k)
          Methdo to convolve the current image with a kernel in real space.
 RealImage extract(int xstart, int ystart, int w, int h)
          Method to extract a region of an real image into a` new RealImage with samples of 1 in both direction.
 RealImage extract(int xstart, int ystart, int w, int h, int xsample, int ysample)
          Method to extract a region of an current image into a` new RealImage
static RealImage fromPGMFile(File file)
          Static method to read PGM image File of type P2 (assi) and P5 (raw)
static RealImage fromPGMFile(String fileName)
          Static method to read a PGM image of type P2 (asci) and P5 (raw) by filename
static RealImage fromPGMStream(DataInputStream input)
          Static method to read a RealImage from a pgm file, formatted P2 and raw P5 pgm files are supported
static RealImage fromTextFile(String fileName, int width, int height)
          Read a RealImage from a asci file that contains only the with one pixel per number in any format accepted by Double.parseDouble().
 BufferedImage getBufferedImage()
          Method to get the image as a displayable BufferedImage of type double.
 ColourScale getColourScale()
          Method to get the ColourScale
 RealSignal getColumn(int i)
          Method to get a Column as a RealSignal, valid only for image in real space.
 RealDataArray getDataArray()
          Method to get the underlying RealDataArray
 BufferedImage getGreyBufferedImage(double min, double max)
          Method to get the RealImage as a BYTE_GRAY BufferedImage which can be displayed with specified min/max.
 RealSignal getRow(int j)
          Method to get a Row as a RealSignal, valid only for image in real space.
 RealStatistics getStatistics()
          Method to get the RealStatistics, which will be calcualte if they are not currently valid.
 RealImage median(ImageFilterKernel k)
          Method to median the current image with a kernel in real space.
 RealImage median(int w, int h)
          Method to apply a smoothing median filter of specified size
static RealImage readImage(File file)
          General ReadImage static method with will read pgm, and any format accepted by the ImageIO (currently pnp,jpeg and gif).
static RealImage readImage(String fileName)
          General ReadImage static method with will read pgm, and any format accepted by the ImageIO (currently pnp,jpeg and gif).
static RealImage readImageIO(File file, int band)
          Static method to read a RealImage a from jpeg/png/gif using the ImageIO inetrface.
 void setColourScale(ColourScale cs)
          Method to set the image colourscale
 
Methods inherited from class uk.ac.ed.ph.signal.Image
add, add, add, centreFourier, conjugate, conjugate, conjugate, fill, fourier, getComplex, getComplex, getConversion, getDataBuffer, getDouble, getDoubleValue, getSpace, getTitle, getType, mult, mult, mult, mult, mult, mult, mult, mult, multConjugate, setComplex, setComplex, setComplex, setComplex, setConversion, setDouble, setDouble, setStatisticsInvalid, setTitle, toString, validStatistics
 
Methods inherited from class uk.ac.ed.ph.signal.Grid2d
getCentre, getDeltaX, getDeltaY, getHeight, getPoint, getPoint, getSample, getSamplePoint, getWidth, getXCentre, getXRange, getYCentre, getYRange, setCentre, setCentre, setHeight, setRange, setRange, setSampleGrid, setSampleGrid, setWidth
 
Methods inherited from class javax.vecmath.Point2d
distance, distanceL1, distanceLinf, distanceSquared
 
Methods inherited from class javax.vecmath.Tuple2d
absolute, absolute, add, add, clamp, clamp, clampMax, clampMax, clampMin, clampMin, epsilonEquals, equals, equals, get, getX, getY, hashCode, interpolate, interpolate, negate, negate, scale, scale, scaleAdd, scaleAdd, set, set, set, set, setX, setY, sub, sub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RealImage

public RealImage(int w,
                 int h)
Construcor to form RealImage of specified size in real space with the pixel values defaulting to zero.

Parameters:
w - the width of the image
h - the heigh of the image

RealImage

public RealImage(RealImage s)
Constrcuor to form new RealImage being a copy of the specified RealImage including the image data.

Parameters:
s - the specifing RealImage

RealImage

public RealImage(RealImage s,
                 boolean copydata)
Constrcuor to form new RealImage being a copy of the specified RealImage. The data will be copied if required, else the data array will be left blank.

Parameters:
s - the specifing RealImage

RealImage

public RealImage(ComplexImage s,
                 int flag)
Constuctor to form a RealImage from a ComplexImage with a conversion flag

Parameters:
s - the ComplexImage
flag - the conversion flag.
See Also:
Complex

RealImage

public RealImage(ComplexImage s)
Constuctor to form a RealImage from a ComplexImage with default conversion flag

Parameters:
s - the ComplexSignal

RealImage

public RealImage(RealDataArray dataArray)
Constuctor to form a RealImage from a specifed RealDataArray

Note that the data is not copied

Parameters:
dataArray - the DataArray holding the image data.
Method Detail

clone

public RealImage clone()
Methed to clone the current image, inclduing the data

Overrides:
clone in class Grid2d
Returns:
RealImage clone of current RealImage

blankcopy

public RealImage blankcopy()
Method to forms a blacnk copy of the corrent RealImage with all parameters copyied, but the image data left blank.

Returns:
RealImage blank copy of current RealImage

getDataArray

public RealDataArray getDataArray()
Method to get the underlying RealDataArray

Returns:
RealDataArray underlying data array

calculateStatistics

public void calculateStatistics()
Method to calcualte the statisticse, even if they are currently flagged as valid.


getStatistics

public RealStatistics getStatistics()
Method to get the RealStatistics, which will be calcualte if they are not currently valid.

Returns:
RealStatistics the image statistics.

getColourScale

public ColourScale getColourScale()
Method to get the ColourScale


setColourScale

public void setColourScale(ColourScale cs)
Method to set the image colourscale


getBufferedImage

public BufferedImage getBufferedImage()
Method to get the image as a displayable BufferedImage of type double. If the colourscale is not pretset it will deafult to a linear grey scale.

Note the actual data array is ued to make the displayable raster.

Returns:
BufferedImage displayable buffered image.

getGreyBufferedImage

public BufferedImage getGreyBufferedImage(double min,
                                          double max)
Method to get the RealImage as a BYTE_GRAY BufferedImage which can be displayed with specified min/max.

If min = max they will be found from the image statistics

Parameters:
min - the min pixel value, zero in BufferedImage
max - the max pixel valie, 255 in BufferedImage
Returns:
BufferedImage displayable image.

getColumn

public RealSignal getColumn(int i)
Method to get a Column as a RealSignal, valid only for image in real space.

Parameters:
i - the column

getRow

public RealSignal getRow(int j)
Method to get a Row as a RealSignal, valid only for image in real space.

Parameters:
j - the row

extract

public RealImage extract(int xstart,
                         int ystart,
                         int w,
                         int h,
                         int xsample,
                         int ysample)
Method to extract a region of an current image into a` new RealImage

Parameters:
xstart - left start pixel
ystart - top start pixel
w - width to be extracted
h - height to be extracted
xsample - sample interval in x direction
ysample - sample internal in y direction

extract

public RealImage extract(int xstart,
                         int ystart,
                         int w,
                         int h)
Method to extract a region of an real image into a` new RealImage with samples of 1 in both direction.

Parameters:
xstart - left start pixel
ystart - top start pixel
w - width to be extracted
h - height to be extracted

fromPGMStream

public static RealImage fromPGMStream(DataInputStream input)
Static method to read a RealImage from a pgm file, formatted P2 and raw P5 pgm files are supported

Parameters:
input - the InputStream

fromPGMFile

public static RealImage fromPGMFile(File file)
Static method to read PGM image File of type P2 (assi) and P5 (raw)

Parameters:
file - the File containing the image
Returns:
RealImage The read PGM image

fromPGMFile

public static RealImage fromPGMFile(String fileName)
Static method to read a PGM image of type P2 (asci) and P5 (raw) by filename

Parameters:
fileName - the file name
Returns:
RealImage The read PGM image

fromTextFile

public static RealImage fromTextFile(String fileName,
                                     int width,
                                     int height)
Read a RealImage from a asci file that contains only the with one pixel per number in any format accepted by Double.parseDouble(). Lines starting with "#" are ignored and assument to be comments.

Parameters:
fileName - the ASCI file
width - the image width
height - the image height
Returns:
RealImage the readin RealImage

readImageIO

public static RealImage readImageIO(File file,
                                    int band)
Static method to read a RealImage a from jpeg/png/gif using the ImageIO inetrface.

Parameters:
file - the File
band - the image band.
Returns:
RealImage the read image.

readImage

public static RealImage readImage(File file)
General ReadImage static method with will read pgm, and any format accepted by the ImageIO (currently pnp,jpeg and gif). If images are tri-colour the GREEN (middle band) is taken.

Parameters:
file - the File
Returns:
RealImage containing the image

readImage

public static RealImage readImage(String fileName)
General ReadImage static method with will read pgm, and any format accepted by the ImageIO (currently pnp,jpeg and gif). If images are tri-colour the GREEN (middle band) is taken.

Parameters:
fileName - the file name
Returns:
RealImage containing the image

convolve

public RealImage convolve(ImageFilterKernel k)
Methdo to convolve the current image with a kernel in real space.

Parameters:
k - the filter kernel

median

public RealImage median(ImageFilterKernel k)
Method to median the current image with a kernel in real space.

Parameters:
k - the filter kernel

median

public RealImage median(int w,
                        int h)
Method to apply a smoothing median filter of specified size

Parameters:
w - width of median kernel
h - height of median kernel