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 ImagePlusCaptures the specified image window and returns it as a newImagePlusinstance.static ImagePlusQueries the user to select one of the currently open images.static ImagePluschooseOpenImage(String title) Queries the user to select one of the currently open images.static ImagePluschooseOpenImage(String title, ImagePlus exclude) Queries the user to select one of the currently open images.static doubleReturns the current magnification (zoom) factor for the specifiedImagePlusinstance.static RectanglesetImageView(ImagePlus im, double magnification, int xa, int ya) Modifies the view of the givenImagePlusimage to the specified magnification (zoom) factor and the anchor position in the source image.static booleanConvenience method forzoomExact(ImagePlus, double, int, int)using default screen margins.static booleanResizes 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_TITLEis 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_TITLEis 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 givenImagePlusimage 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. Otherwisenullis 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,
nullotherwise
-
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 specifiedImagePlusinstance. 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 newImagePlusinstance. Uses ImageJ's built-inScreenGrabberplugin.- Parameters:
im- the image, which must be currently open (displayed)- Returns:
- a new image with the grabbed contents
-