java.lang.Object
imagingbook.common.ij.GuiTools
Defines static helper methods related to ImageJ's GUI.
- Version:
- 2022/09/15
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic ImagePlus
Captures the specified image window and returns it as a newImagePlus
instance.static ImagePlus
Queries the user to select one of the currently open images.static ImagePlus
chooseOpenImage
(String title) Queries the user to select one of the currently open images.static ImagePlus
chooseOpenImage
(String title, ImagePlus exclude) Queries the user to select one of the currently open images.static double
Returns the current magnification (zoom) factor for the specifiedImagePlus
instance.static Rectangle
setImageView
(ImagePlus im, double magnification, int xa, int ya) Modifies the view of the givenImagePlus
image to the specified magnification (zoom) factor and the anchor position in the source image.static boolean
Convenience method forzoomExact(ImagePlus, double, int, int)
using default screen margins.static boolean
Resizes the window of the given image to fit an arbitrary, user-specified magnification factor.
-
Field Details
-
DEFAULT_DIALOG_TITLE
- See Also:
-
-
Method Details
-
chooseOpenImage
Queries the user to select one of the currently open images.- Parameters:
title
- name of the dialog window (if null,DEFAULT_DIALOG_TITLE
is used)exclude
- image to exclude from being selected (typically the current image)- Returns:
- a reference to the chosen image (
ImagePlus
) or null, if the dialog was cancelled
-
chooseOpenImage
Queries the user to select one of the currently open images.- Parameters:
title
- name of the dialog window (if null,DEFAULT_DIALOG_TITLE
is used)- Returns:
- a reference to the chosen image (
ImagePlus
) or null, if the dialog was cancelled
-
chooseOpenImage
Queries the user to select one of the currently open images.- Returns:
- a reference to the chosen image (
ImagePlus
) or null, if the dialog was cancelled
-
setImageView
Modifies the view of the givenImagePlus
image to the specified magnification (zoom) factor and the anchor position in the source image. The size of the image window remains unchanged. The specified anchor point is the top-left corner of the source rectangle, both coordinates must be positive. The method fails (does nothing and returnsnull
) if the resulting source rectangle does not fit into the image. If successful, the view is modified and the resulting source rectangle is returned. Otherwisenull
is returned.- Parameters:
im
- the image, which must be currently open (displayed)magnification
- the new magnification factor (1.0 = 100%)xa
- the x-coordinate of the anchor pointya
- the y-coordinate of the anchor point- Returns:
- the resulting source rectangle if successful,
null
otherwise
-
zoomExact
Resizes the window of the given image to fit an arbitrary, user-specified magnification factor. The resulting window size is limited by the current screen size. The window size is reduced if too large but the given magnification factor remains always unchanged.
Adapted from https://albert.rierol.net/plugins/Zoom_Exact.java by Albert Cardona @ 2006 General Public License applies.- Parameters:
im
- the image, which must be currently open (displayed)magnification
- the new magnification factor (1.0 = 100%)marginX
- horizontal screen marginmarginY
- vertical screen margin- Returns:
- true if successful, false otherwise
-
zoomExact
Convenience method forzoomExact(ImagePlus, double, int, int)
using default screen margins.- Parameters:
im
- the image, which must be currently open (displayed)magnification
- the new magnification factor (1.0 = 100%)- Returns:
- true if successful, false otherwise
-
getMagnification
Returns the current magnification (zoom) factor for the specifiedImagePlus
instance. Throws an exception if the image is currently not displayed.- Parameters:
im
- the image, which must be currently open (displayed)- Returns:
- the magnification factor
-
captureImage
Captures the specified image window and returns it as a newImagePlus
instance. Uses ImageJ's built-inScreenGrabber
plugin.- Parameters:
im
- the image, which must be currently open (displayed)- Returns:
- a new image with the grabbed contents
-