|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectij.ImagePlus
public class ImagePlus
An ImagePlus contain an ImageProcessor (2D image) or an ImageStack (3D, 4D or 5D image). It also includes metadata (spatial calibration and possibly the directory/file where it was read from). The ImageProcessor contains the pixel data (8-bit, 16-bit, float or RGB) of the 2D image and some basic methods to manipulate it. An ImageStack is essentually a list ImageProcessors of same type and size.
ImageProcessor
,
ImageStack
,
ImageWindow
,
ImageCanvas
Field Summary | |
---|---|
boolean |
changes
True if any changes have been made to this image. |
protected static int |
CLOSED
|
static int |
COLOR_256
8-bit indexed color |
static int |
COLOR_RGB
32-bit RGB color |
protected boolean |
compositeImage
|
protected int |
currentSlice
|
protected boolean |
dimensionsSet
|
static int |
GRAY16
16-bit grayscale (unsigned) |
static int |
GRAY32
32-bit floating-point grayscale |
static int |
GRAY8
8-bit grayscale (unsigned) |
protected int |
height
|
protected Image |
img
|
protected ImageProcessor |
ip
|
protected boolean |
locked
|
protected int |
nChannels
|
protected int |
nFrames
|
protected int |
nSlices
|
protected static int |
OPENED
|
protected Roi |
roi
|
protected static int |
UPDATED
|
protected int |
width
|
protected ImageWindow |
win
|
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Fields inherited from interface ij.measure.Measurements |
---|
ADD_TO_OVERLAY, AREA, AREA_FRACTION, CENTER_OF_MASS, CENTROID, CIRCULARITY, ELLIPSE, FERET, INTEGRATED_DENSITY, INVERT_Y, KURTOSIS, LABELS, LIMIT, MAX_STANDARDS, MEAN, MEDIAN, MIN_MAX, MODE, PERIMETER, RECT, SCIENTIFIC_NOTATION, SHAPE_DESCRIPTORS, SKEWNESS, SLICE, STACK_POSITION, STD_DEV |
Constructor Summary | |
---|---|
ImagePlus()
Constructs an uninitialized ImagePlus. |
|
ImagePlus(String pathOrURL)
Constructs an ImagePlus from a TIFF, BMP, DICOM, FITS, PGM, GIF or JPRG specified by a path or from a TIFF, DICOM, GIF or JPEG specified by a URL. |
|
ImagePlus(String title,
Image img)
Constructs an ImagePlus from an Image or BufferedImage. |
|
ImagePlus(String title,
ImageProcessor ip)
Constructs an ImagePlus from an ImageProcessor. |
|
ImagePlus(String title,
ImageStack stack)
Constructs an ImagePlus from a stack. |
Method Summary | |
---|---|
static void |
addImageListener(ImageListener listener)
|
Object |
clone()
Returns a shallow copy of this ImagePlus. |
void |
close()
Closes this image and sets the ImageProcessor to null. |
int[] |
convertIndexToPosition(int n)
Converts the stack index 'n' (one-based) into a hyperstack position (channel, slice, frame). |
void |
copy()
Copies the contents of the current selection, or the entire image if there is no selection, to the internal clipboard. |
void |
copy(boolean cut)
Copies the contents of the current selection to the internal clipboard. |
void |
copyAttributes(ImagePlus imp)
Copies attributes (name, ID, calibration, path) of the specified image to this image. |
void |
copyScale(ImagePlus imp)
Copies the calibration of the specified image to this image. |
ImageStack |
createEmptyStack()
Returns an empty image stack that has the same width, height and color table as this image. |
ImagePlus |
createHyperStack(String title,
int channels,
int slices,
int frames,
int bitDepth)
This method has been replaced by IJ.createHyperStack(). |
ImagePlus |
createImagePlus()
Returns a new ImagePlus with this image's attributes (e.g. |
LookUpTable |
createLut()
Creates a LookUpTable object that corresponds to this image. |
void |
createNewRoi(int sx,
int sy)
Starts the process of creating a new selection, where sx and sy are the starting screen coordinates. |
void |
deleteRoi()
Deletes the current region of interest. |
void |
draw()
Draws the image. |
void |
draw(int x,
int y,
int width,
int height)
Draws image and roi outline using a clip rect. |
ImagePlus |
duplicate()
Returns a copy (clone) of this ImagePlus. |
ImagePlus |
flatten()
Returns a "flattened" version of this image, in RGB format. |
void |
flattenStack()
Flattens all slices of this stack or HyperStack. |
void |
flush()
Sets the ImageProcessor, Roi, AWT Image and stack image arrays to null. |
int |
getBitDepth()
Returns the bit depth, 8, 16, 24 (RGB) or 32. |
BufferedImage |
getBufferedImage()
Returns a copy of this image as an 8-bit or RGB BufferedImage. |
int |
getBytesPerPixel()
Returns the number of bytes per pixel. |
int |
getC()
Returns the current hyperstack channel position. |
Calibration |
getCalibration()
Returns this image's calibration. |
ImageCanvas |
getCanvas()
Returns the ImageCanvas being used to display this image, or null. |
int |
getChannel()
|
ImageProcessor |
getChannelProcessor()
Returns a reference to the current ImageProcessor. |
static ImagePlus |
getClipboard()
Returns the internal clipboard or null if the internal clipboard is empty. |
int |
getCompositeMode()
Returns the display mode (IJ.COMPOSITE, IJ.COLOR or IJ.GRAYSCALE) if this is a CompositeImage, otherwise returns -1. |
int |
getCurrentSlice()
Returns the current stack index (one-based) or 1 if this is a single image. |
static int |
getDefault16bitRange()
Returns the default 16-bit display range, 0 (auto-scaling), 8, 10, 12, 15 or 16. |
int[] |
getDimensions()
Returns the dimensions of this image (width, height, nChannels, nSlices, nFrames) as a 5 element int array. |
int[] |
getDimensions(boolean varify)
|
double |
getDisplayRangeMax()
|
double |
getDisplayRangeMin()
|
FileInfo |
getFileInfo()
Returns a FileInfo object containing information, including the pixel array, needed to save this image. |
int |
getFrame()
|
Calibration |
getGlobalCalibration()
Returns the system-wide calibration, or null. |
int |
getHeight()
|
boolean |
getHideOverlay()
|
int |
getID()
Returns this image's unique numeric ID. |
Image |
getImage()
Returns this image as a AWT image. |
ImageStack |
getImageStack()
Returns the base image stack. |
int |
getImageStackSize()
If this is a stack, returns the actual number of images in the stack, else returns 1. |
String |
getInfoProperty()
Returns the "Info" property string, or null if it is not found. |
Calibration |
getLocalCalibration()
Returns this image's local calibration, ignoring the "Global" calibration flag. |
String |
getLocationAsString(int x,
int y)
Converts the current cursor location to a string. |
LUT[] |
getLuts()
|
ImageProcessor |
getMask()
For images with irregular ROIs, returns a byte mask, otherwise, returns null. |
int |
getNChannels()
Returns the number of channels. |
int |
getNDimensions()
Returns the number of dimensions (2, 3, 4 or 5). |
int |
getNFrames()
Returns the number of frames (time-points). |
int |
getNSlices()
Returns the image depth (number of z-slices). |
boolean |
getOpenAsHyperStack()
|
FileInfo |
getOriginalFileInfo()
Returns the FileInfo object that was used to open this image. |
Overlay |
getOverlay()
Returns the current overly, or null if this image does not have an overlay. |
int[] |
getPixel(int x,
int y)
Returns the pixel value at (x,y) as a 4 element array. |
ImageProcessor |
getProcessor()
Returns a reference to the current ImageProcessor. |
String |
getProp(String key)
Returns the value from the "Info" property string associated with 'key', or null if the key is not found. |
Properties |
getProperties()
Returns this image's Properties. |
Object |
getProperty(String key)
Returns the property associated with 'key'. |
Roi |
getRoi()
Returns the current selection, or null if there is no selection. |
String |
getShortTitle()
Returns a shortened version of image name that does not include spaces or a file name extension. |
int |
getSlice()
|
ImageStack |
getStack()
Returns the image stack. |
int |
getStackIndex(int channel,
int slice,
int frame)
Returns that stack index (one-based) corresponding to the specified position. |
int |
getStackSize()
If this is a stack, returns the number of slices, else returns 1. |
long |
getStartTime()
Returns the time in milliseconds when startTiming() was last called. |
ImageStatistics |
getStatistics()
Returns an ImageStatistics object generated using the standard measurement options (area, mean, mode, min and max). |
ImageStatistics |
getStatistics(int mOptions)
Returns an ImageStatistics object generated using the specified measurement options. |
ImageStatistics |
getStatistics(int mOptions,
int nBins)
Returns an ImageStatistics object generated using the specified measurement options and histogram bin count. |
ImageStatistics |
getStatistics(int mOptions,
int nBins,
double histMin,
double histMax)
Returns an ImageStatistics object generated using the specified measurement options, histogram bin count and histogram range. |
int |
getT()
Returns the current hyperstack frame position. |
String |
getTitle()
Returns the image name. |
int |
getType()
Returns the current image type (ImagePlus.GRAY8, ImagePlus.GRAY16, ImagePlus.GRAY32, ImagePlus.COLOR_256 or ImagePlus.COLOR_RGB). |
int |
getWidth()
|
ImageWindow |
getWindow()
Returns the ImageWindow that is being used to display this image. |
int |
getZ()
Returns the current hyperstack slice position. |
void |
hide()
Closes the window, if any, that is displaying this image. |
boolean |
imageUpdate(Image img,
int flags,
int x,
int y,
int w,
int h)
Used by ImagePlus to monitor loading of images. |
boolean |
isComposite()
Returns true if this is a CompositeImage. |
boolean |
isDisplayedHyperStack()
Returns 'true' if this is a hyperstack currently being displayed in a StackWindow. |
boolean |
isHyperStack()
Returns 'true' if this image is a hyperstack. |
boolean |
isInvertedLut()
Returns true is this image uses an inverting LUT that displays zero as white and 255 as black. |
boolean |
isLocked()
Returns 'true' if the image is locked. |
boolean |
isProcessor()
|
boolean |
isVisible()
Returns true if this image is currently being displayed in a window. |
void |
killRoi()
Deletes the current region of interest. |
void |
killStack()
|
boolean |
lock()
Locks the image so other threads can test to see if it is in use. |
boolean |
lockSilently()
Similar to lock, but doesn't beep and display an error message if the attempt to lock the image fails. |
void |
mouseMoved(int x,
int y)
Displays the cursor coordinates and pixel value in the status bar. |
protected void |
notifyListeners(int id)
|
void |
paste()
Inserts the contents of the internal clipboard into the active image. |
static void |
removeImageListener(ImageListener listener)
|
void |
repaintWindow()
Calls draw to draw the image and also repaints the image window to force the information displayed above the image (dimension, type, size) to be updated. |
static void |
resetClipboard()
Clears the internal clipboard. |
void |
resetDisplayRange()
|
void |
resetStack()
|
void |
restoreRoi()
|
void |
revert()
Implements the File/Revert command. |
void |
saveRoi()
|
void |
setActivated()
Called by ImageWindow.windowActivated(). |
void |
setAntialiasRendering(boolean antialiasRendering)
Enable/disable use of antialiasing by the flatten() method. |
void |
setC(int channel)
Sets the hyperstack channel position (one based). |
void |
setCalibration(Calibration cal)
Sets this image's calibration. |
void |
setColor(Color c)
Sets current foreground color. |
static void |
setDefault16bitRange(int bitDepth)
Set the default 16-bit display range, where 'bitDepth' must be 0 (auto-scaling), 8 (0-255), 10 (0-1023), 12 (0-4095, 15 (0-32767) or 16 (0-65535). |
void |
setDimensions(int nChannels,
int nSlices,
int nFrames)
Sets the 3rd, 4th and 5th dimensions, where nChannels *nSlices *nFrames
must be equal to the stack size. |
void |
setDisplayRange(double min,
double max)
Sets the display range of the current channel. |
void |
setDisplayRange(double min,
double max,
int channels)
Sets the display range of specified channels in an RGB image, where 4=red, 2=green, 1=blue, 6=red+green, etc. |
void |
setFileInfo(FileInfo fi)
Saves this image's FileInfo so it can be later retieved using getOriginalFileInfo(). |
void |
setGlobalCalibration(Calibration global)
Sets the system-wide calibration. |
void |
setHideOverlay(boolean hide)
|
void |
setIgnoreFlush(boolean ignoreFlush)
|
void |
setImage(Image img)
Replaces the image, if any, with the one specified. |
void |
setImage(ImagePlus imp)
Replaces this image with the specified ImagePlus. |
void |
setOpenAsHyperStack(boolean openAsHyperStack)
|
void |
setOverlay(Overlay overlay)
Installs a list of ROIs that will be drawn on this image as a non-destructive overlay. |
void |
setOverlay(Roi roi,
Color strokeColor,
int strokeWidth,
Color fillColor)
Creates an Overlay from the specified ROI, and assigns it to this image. |
void |
setOverlay(Shape shape,
Color color,
BasicStroke stroke)
Creates an Overlay from the specified Shape, Color and BasicStroke, and assigns it to this image. |
void |
setPosition(int n)
Set the current hyperstack position based on the stack index 'n' (one-based). |
void |
setPosition(int channel,
int slice,
int frame)
Sets the current hyperstack position and updates the display, where 'channel', 'slice' and 'frame' are one-based indexes. |
void |
setPositionWithoutUpdate(int channel,
int slice,
int frame)
Sets the current hyperstack position without updating the display, where 'channel', 'slice' and 'frame' are one-based indexes. |
void |
setProcessor(ImageProcessor ip)
Replaces the ImageProcessor with the one specified and updates the display. |
void |
setProcessor(String title,
ImageProcessor ip)
Replaces the ImageProcessor with the one specified and updates the display. |
void |
setProperty(String key,
Object value)
Adds a key-value pair to this image's properties. |
void |
setRoi(int x,
int y,
int width,
int height)
Creates a rectangular selection. |
void |
setRoi(Rectangle r)
Creates a rectangular selection. |
void |
setRoi(Roi newRoi)
Assigns the specified ROI to this image and displays it. |
void |
setRoi(Roi newRoi,
boolean updateDisplay)
Assigns 'newRoi' to this image and displays it if 'updateDisplay' is true. |
void |
setSlice(int n)
Displays the specified stack image, where 1<=n<=stackSize. |
void |
setSliceWithoutUpdate(int n)
Displays the specified stack image (1<=n<=stackSize) without updating the display. |
void |
setStack(ImageStack stack)
Replaces the image with the specified stack and updates the display. |
void |
setStack(ImageStack stack,
int nChannels,
int nSlices,
int nFrames)
|
void |
setStack(String title,
ImageStack newStack)
Replaces the image with the specified stack and updates the display. |
void |
setT(int frame)
Sets the hyperstack frame position (one based). |
void |
setTitle(String title)
Sets the image name. |
protected void |
setType(int type)
|
void |
setWindow(ImageWindow win)
This method should only be called from an ImageWindow. |
void |
setZ(int slice)
Sets the hyperstack slice position (one based). |
void |
show()
Opens a window to display this image and clears the status bar. |
void |
show(String statusMessage)
Opens a window to display this image and displays 'statusMessage' in the status bar. |
void |
startTiming()
Calls System.currentTimeMillis() to save the current time so it can be retrieved later using getStartTime() to calculate the elapsed time of an operation. |
String |
toString()
|
void |
trimProcessor()
Frees RAM by setting the snapshot (undo) buffer in the current ImageProcessor to null. |
void |
unlock()
Unlocks the image. |
void |
updateAndDraw()
Updates this image from the pixel data in its associated ImageProcessor, then displays it. |
void |
updateAndRepaintWindow()
Calls updateAndDraw to update from the pixel data and draw the image, and also repaints the image window to force the information displayed above the image (dimension, type, size) to be updated. |
void |
updateChannelAndDraw()
Updates this image from the pixel data in its associated ImageProcessor, then displays it. |
void |
updateImage()
ImageCanvas.paint() calls this method when the ImageProcessor has generated new image. |
void |
updatePosition(int c,
int z,
int t)
|
void |
updateStatusbarValue()
Redisplays the (x,y) coordinates and pixel value (which may have changed) in the status bar. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int GRAY8
public static final int GRAY16
public static final int GRAY32
public static final int COLOR_256
public static final int COLOR_RGB
public boolean changes
protected Image img
protected ImageProcessor ip
protected ImageWindow win
protected Roi roi
protected int currentSlice
protected static final int OPENED
protected static final int CLOSED
protected static final int UPDATED
protected boolean compositeImage
protected int width
protected int height
protected boolean locked
protected int nChannels
protected int nSlices
protected int nFrames
protected boolean dimensionsSet
Constructor Detail |
---|
public ImagePlus()
public ImagePlus(String title, Image img)
public ImagePlus(String title, ImageProcessor ip)
public ImagePlus(String pathOrURL)
public ImagePlus(String title, ImageStack stack)
Method Detail |
---|
public boolean lock()
public boolean lockSilently()
public void unlock()
public void draw()
public void draw(int x, int y, int width, int height)
public void updateAndDraw()
public void updateChannelAndDraw()
public ImageProcessor getChannelProcessor()
public LUT[] getLuts()
public void repaintWindow()
public void updateAndRepaintWindow()
public void updateImage()
public void hide()
public void close()
public void show()
public void show(String statusMessage)
public void setActivated()
public Image getImage()
public BufferedImage getBufferedImage()
ShortProcessor.get16BitBufferedImage()
public int getID()
public void setImage(Image img)
public void setImage(ImagePlus imp)
public void setProcessor(ImageProcessor ip)
public void setProcessor(String title, ImageProcessor ip)
public void setStack(ImageStack stack)
public void setStack(String title, ImageStack newStack)
public void setStack(ImageStack stack, int nChannels, int nSlices, int nFrames)
public void setFileInfo(FileInfo fi)
public ImageWindow getWindow()
public boolean isVisible()
public void setWindow(ImageWindow win)
public ImageCanvas getCanvas()
public void setColor(Color c)
public boolean isProcessor()
public ImageProcessor getProcessor()
public void trimProcessor()
public ImageProcessor getMask()
public ImageStatistics getStatistics()
public class Get_Statistics implements PlugIn { public void run(String arg) { ImagePlus imp = IJ.getImage(); ImageStatistics stats = imp.getStatistics(); IJ.log("Area: "+stats.area); IJ.log("Mean: "+stats.mean); IJ.log("Max: "+stats.max); } }
ImageStatistics
,
ImageStatistics.getStatistics(ij.process.ImageProcessor, int, ij.measure.Calibration)
public ImageStatistics getStatistics(int mOptions)
public class Get_Statistics implements PlugIn, Measurements { public void run(String arg) { ImagePlus imp = IJ.getImage(); ImageStatistics stats = imp.getStatistics(MEDIAN+CENTROID); IJ.log("Median: "+stats.median); IJ.log("xCentroid: "+stats.xCentroid); IJ.log("yCentroid: "+stats.yCentroid); } }
ImageStatistics
,
Measurements
public ImageStatistics getStatistics(int mOptions, int nBins)
public ImageStatistics getStatistics(int mOptions, int nBins, double histMin, double histMax)
public String getTitle()
public String getShortTitle()
public void setTitle(String title)
public int getWidth()
public int getHeight()
public int getStackSize()
public int getImageStackSize()
public void setDimensions(int nChannels, int nSlices, int nFrames)
nChannels
*nSlices
*nFrames
must be equal to the stack size.
public boolean isHyperStack()
public int getNDimensions()
public boolean isDisplayedHyperStack()
public int getNChannels()
public int getNSlices()
public int getNFrames()
public int[] getDimensions()
public int[] getDimensions(boolean varify)
public int getType()
getBitDepth()
public int getBitDepth()
public int getBytesPerPixel()
protected void setType(int type)
public void setProperty(String key, Object value)
public Object getProperty(String key)
public Properties getProperties()
public String getProp(String key)
public String getInfoProperty()
public LookUpTable createLut()
public boolean isInvertedLut()
public int[] getPixel(int x, int y)
public ImageStack createEmptyStack()
public ImageStack getStack()
setStack()
to update the image and
the window that is displaying it.
setStack(ij.ImageStack)
public ImageStack getImageStack()
public int getCurrentSlice()
public int getChannel()
public int getSlice()
public int getFrame()
public void killStack()
public void setPosition(int channel, int slice, int frame)
public void setPositionWithoutUpdate(int channel, int slice, int frame)
public void setC(int channel)
public void setZ(int slice)
public void setT(int frame)
public int getC()
public int getZ()
public int getT()
public int getStackIndex(int channel, int slice, int frame)
public void resetStack()
public void setPosition(int n)
public int[] convertIndexToPosition(int n)
public void setSlice(int n)
setPosition(int, int, int)
,
setC(int)
,
setZ(int)
,
setT(int)
public void setSliceWithoutUpdate(int n)
public Roi getRoi()
public void setRoi(Roi newRoi)
roi
is null or its width or height is zero.
public void setRoi(Roi newRoi, boolean updateDisplay)
public void setRoi(int x, int y, int width, int height)
public void setRoi(Rectangle r)
public void createNewRoi(int sx, int sy)
public void deleteRoi()
public void killRoi()
public void saveRoi()
public void restoreRoi()
public void revert()
public FileInfo getFileInfo()
FileInfo
,
getOriginalFileInfo()
,
setFileInfo(ij.io.FileInfo)
public FileInfo getOriginalFileInfo()
FileInfo
,
getFileInfo()
public boolean imageUpdate(Image img, int flags, int x, int y, int w, int h)
imageUpdate
in interface ImageObserver
public void flush()
public void setIgnoreFlush(boolean ignoreFlush)
public ImagePlus duplicate()
public ImagePlus createImagePlus()
public ImagePlus createHyperStack(String title, int channels, int slices, int frames, int bitDepth)
public void copyScale(ImagePlus imp)
public void copyAttributes(ImagePlus imp)
public void startTiming()
public long getStartTime()
public Calibration getCalibration()
public void setCalibration(Calibration cal)
public void setGlobalCalibration(Calibration global)
public Calibration getGlobalCalibration()
public Calibration getLocalCalibration()
public void mouseMoved(int x, int y)
public void updateStatusbarValue()
public String getLocationAsString(int x, int y)
public void copy()
public void copy(boolean cut)
cut
is true.
public void paste()
public static ImagePlus getClipboard()
public static void resetClipboard()
protected void notifyListeners(int id)
public static void addImageListener(ImageListener listener)
public static void removeImageListener(ImageListener listener)
public boolean isLocked()
public void setOpenAsHyperStack(boolean openAsHyperStack)
public boolean getOpenAsHyperStack()
public boolean isComposite()
public int getCompositeMode()
public void setDisplayRange(double min, double max)
public double getDisplayRangeMin()
public double getDisplayRangeMax()
public void setDisplayRange(double min, double max, int channels)
public void resetDisplayRange()
public static void setDefault16bitRange(int bitDepth)
public static int getDefault16bitRange()
public void updatePosition(int c, int z, int t)
public ImagePlus flatten()
public void flattenStack()
UnsupportedOperationException
- if this imagepublic void setOverlay(Overlay overlay)
Roi.setStrokeColor(java.awt.Color)
,
Roi.setStrokeWidth(float)
,
Roi.setFillColor(java.awt.Color)
,
Roi.setLocation(int, int)
,
Roi.setNonScalable(boolean)
public void setOverlay(Shape shape, Color color, BasicStroke stroke)
setOverlay(ij.gui.Overlay)
,
Roi.setStrokeColor(java.awt.Color)
,
Roi.setStrokeWidth(float)
public void setOverlay(Roi roi, Color strokeColor, int strokeWidth, Color fillColor)
setOverlay(ij.gui.Overlay)
public Overlay getOverlay()
public void setHideOverlay(boolean hide)
public boolean getHideOverlay()
public void setAntialiasRendering(boolean antialiasRendering)
public Object clone()
clone
in class Object
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |