Package qupath.lib.gui.viewer.overlays
Class BufferedImageOverlay
java.lang.Object
qupath.lib.gui.viewer.overlays.AbstractOverlay
qupath.lib.gui.viewer.overlays.AbstractImageOverlay
qupath.lib.gui.viewer.overlays.BufferedImageOverlay
- All Implemented Interfaces:
ChangeListener<ImageData<BufferedImage>>
,PathOverlay
public class BufferedImageOverlay
extends AbstractImageOverlay
implements ChangeListener<ImageData<BufferedImage>>
An overlay used to display one or more
BufferedImage
objects on top of a primary image shown in a viewer.
The scaling for the BufferedImage
is determined by an associated ImageRegion
.
- Author:
- Pete Bankhead
-
Property Summary
Properties inherited from class qupath.lib.gui.viewer.overlays.AbstractImageOverlay
interpolation
-
Nested Class Summary
Nested classes/interfaces inherited from class qupath.lib.gui.viewer.overlays.AbstractOverlay
AbstractOverlay.LocationStringFunction
-
Constructor Summary
ConstructorDescriptionBufferedImageOverlay
(OverlayOptions options) Create an empty overlay without any images to display.BufferedImageOverlay
(OverlayOptions options, Map<? extends ImageRegion, BufferedImage> regions) Create an overlay to display multiple image regions.BufferedImageOverlay
(OverlayOptions options, ImageRegion region, BufferedImage img) Create an overlay to display one specified image region.BufferedImageOverlay
(QuPathViewer viewer, BufferedImage img) Create an overlay to show an image rescaled to overlay the entire current image in the specified viewer.BufferedImageOverlay
(QuPathViewer viewer, Map<ImageRegion, BufferedImage> map) Create an overlay to show an image rescaled to overlay the entire current image in the specified viewer.BufferedImageOverlay
(QuPathViewer viewer, OverlayOptions options, Map<? extends ImageRegion, BufferedImage> regions) Create an overlay to display multiple image regions. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAllRegions
(ImageServer<BufferedImage> server, int level) Add all regions for a specific level of anImageServer
.void
changed
(ObservableValue<? extends ImageData<BufferedImage>> observable, ImageData<BufferedImage> oldValue, ImageData<BufferedImage> newValue) Get an unmodifiableMap
containing image regions to paint on this overlay.void
paintOverlay
(Graphics2D g2d, ImageRegion imageRegion, double downsampleFactor, ImageData<BufferedImage> imageData, boolean paintCompletely) Paint the overlay to a graphics object.void
setColorModel
(ColorModel colorModel) Optionally set a customColorModel
.Methods inherited from class qupath.lib.gui.viewer.overlays.AbstractImageOverlay
getInterpolation, interpolationProperty, setInterpolation, setInterpolation
Methods inherited from class qupath.lib.gui.viewer.overlays.AbstractOverlay
getAlphaComposite, getLocationString, getLocationStringFunction, getOpacity, getOverlayOptions, getPreferredOverlayColor, isVisible, setAlphaComposite, setLocationStringFunction, setOpacity, setPreferredOverlayColor
-
Constructor Details
-
BufferedImageOverlay
Create an overlay to show an image rescaled to overlay the entire current image in the specified viewer.- Parameters:
viewer
-img
-
-
BufferedImageOverlay
Create an overlay to show an image rescaled to overlay the entire current image in the specified viewer.- Parameters:
viewer
-map
-
-
BufferedImageOverlay
Create an empty overlay without any images to display.- Parameters:
options
-
-
BufferedImageOverlay
Create an overlay to display one specified image region.- Parameters:
options
-region
-img
-
-
BufferedImageOverlay
public BufferedImageOverlay(OverlayOptions options, Map<? extends ImageRegion, BufferedImage> regions) Create an overlay to display multiple image regions.- Parameters:
options
-regions
-
-
BufferedImageOverlay
public BufferedImageOverlay(QuPathViewer viewer, OverlayOptions options, Map<? extends ImageRegion, BufferedImage> regions) Create an overlay to display multiple image regions.- Parameters:
viewer
-options
-regions
-
-
-
Method Details
-
addAllRegions
Add all regions for a specific level of anImageServer
. Note that this results in all regions being read immediately. Therefore it should only be used for 'small' images that can be held in main memory.- Parameters:
server
- the server whose tiles should be drawn on the overlaylevel
- the level from which to request regions; for the highest available resolution, use 0- Throws:
IOException
-
setColorModel
Optionally set a customColorModel
. This makes it possible to display theBufferedImage
with a different color model than its original model.- Parameters:
colorModel
-
-
getColorModel
- Returns:
- the custom color model, if any is found.
-
changed
public void changed(ObservableValue<? extends ImageData<BufferedImage>> observable, ImageData<BufferedImage> oldValue, ImageData<BufferedImage> newValue) - Specified by:
changed
in interfaceChangeListener<ImageData<BufferedImage>>
-
getRegionMap
Get an unmodifiableMap
containing image regions to paint on this overlay.- Returns:
-
paintOverlay
public void paintOverlay(Graphics2D g2d, ImageRegion imageRegion, double downsampleFactor, ImageData<BufferedImage> imageData, boolean paintCompletely) Description copied from interface:PathOverlay
Paint the overlay to a graphics object. The graphics object will have a transform applied to it, so the painting should make use of coordinates in the original image space.- Specified by:
paintOverlay
in interfacePathOverlay
- Overrides:
paintOverlay
in classAbstractImageOverlay
- Parameters:
g2d
- Graphics2D object to which drawing should be performed. This should have any transform already applied to it.imageRegion
- The maximum image region that should be shown.downsampleFactor
- The downsample factor at which the overlay will be viewed. There is no need for rescaling according to this value since it has already been applied to theGraphics2D
as part of itsAffineTransform
, however it may optionally be needed within the method e.g. to correct line thicknesses.imageData
- theImageData
associated with this overlay. If the overlay is being displayed on a viewer, this is theImageData
open within the viewer. Not all overlays require this, and it may be null.paintCompletely
- If true, the method is permitted to return without completely painting everything, for performance reasons.
-