Package com.xinapse.multisliceimage.roi
Interface CanAddROIToFrame
public interface CanAddROIToFrame
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Add anROI
to the frame.void
void
exchangeROIs
(List<ROI> oldROIs, List<ROI> newROIs, ROIEditAction editAction) getDeletedROIs
(int slice) getFrame()
byte[]
Returns the current set of both current and deleted ROIs, outputted as text to a byte[].getROIs()
getROIs
(int slice) Returns the number of the selected image slice in thisCanAddROIToFrame
.boolean
Tests whether aCanAddROIToFrame
has current (not deleted)ROI
s.void
maskImage
(int slice, List<ROI> ROIs, MaskAction maskAction, double maskValue, CombineMode combineMode) Use the suppliedROI
s in the slice to mask the image.void
previewROIs
(List<ROI> rois) void
Shows an error message in theCanAddROIToFrame
.void
Show the tool that is used to interactively create, modify and deleteROI
s.void
showStatus
(String message) Shows a status message in theCanAddROIToFrame
.boolean
Unload allROI
s from the frame.boolean
unloadROIs
(boolean noQuery) Unload allROI
s from the frame, optionally unloading without querying the user.boolean
unloadROIs
(Component c, boolean noQuery) Unload allROI
s from theCanAddROIToFrame
, optionally unloading without querying the user.boolean
unloadROIs
(List<ROI> roisToUnload, Component c, boolean noQuery) Unload the suppliedROI
s from theCanAddROIToFrame
, optionally unloading without querying the user.
-
Method Details
-
getFrame
JFrame getFrame() -
getSelectedSlice
Integer getSelectedSlice()Returns the number of the selected image slice in thisCanAddROIToFrame
. Image slices are indexed from zero.- Returns:
- the number of the selected image slice in this
CanAddROIToFrame
; returnsnull
if the image does not have a selected slice, if the selected slice is outside the slice range of the image, or if there is no image currently loaded.
-
addROIs
- Parameters:
rois
- theList
ofROI
s to add.- Throws:
ROIException
- if one or more of theROI
s couldn't be added.
-
addROI
Add anROI
to the frame.- Parameters:
roi
- theROI
to add.- Returns:
- true if the addition was successful.
-
exchangeROIs
void exchangeROIs(List<ROI> oldROIs, List<ROI> newROIs, ROIEditAction editAction) throws ROIException - Parameters:
oldROIs
- the currentList
ofROI
s to change.newROIs
- the newList
ofROI
s that will be substituted.editAction
- theROIEditAction
that records the action that resulted in the exchange.- Throws:
ROIException
- if the exchange couldn't be made.
-
previewROIs
-
hasCurrentROIs
Tests whether aCanAddROIToFrame
has current (not deleted)ROI
s.- Returns:
- true if the Frame has current (not deleted)
ROI
s. - Throws:
ROIException
- if there is no image displayed.
-
getROIs
- Returns:
- a
List
of current (not deleted)ROI
s for the image displayed in thisCanAddROIToFrame
. Returns an empty list if the image has no ROIs. - Throws:
ROIException
- if there is no image displayed.
-
getROIs
- Parameters:
slice
- the slice number for the image.- Returns:
- a
List
of current (not deleted)ROI
s for one slice of the image displayed in thisCanAddROIToFrame
. Returns an empty list of there is no image displayed or the image has no ROIs in the given slice. - Throws:
ROIException
- if the slice number is invalid.
-
getSelectedROIs
- Returns:
- a
List
of selectedROI
s for the image displayed in thisCanAddROIToFrame
. Returns an empty list if there is no image displayed or no selected ROIs.
-
getDeletedROIs
- Returns:
- a
List
of deletedROI
s for the image displayed in thisCanAddROIToFrame
. Will return an empty list if the image has no deleted ROIs. - Throws:
ROIException
- if there is no image displayed.
-
getROIOutput
Returns the current set of both current and deleted ROIs, outputted as text to a byte[].- Returns:
- the ROIs, saved into the byte[].
- Throws:
IOException
- if an error occurs while writing the ROIs to the byte[].
-
getDeletedROIs
- Parameters:
slice
- the slice number for the image.- Returns:
- a
List
of deletedROI
s for one slice of the image displayed in thisCanAddROIToFrame
. Returns an empty list of there is no image displayed or the image has no deleted ROIs in the given slice. - Throws:
ROIException
- if the slice number is invalid.
-
maskImage
void maskImage(int slice, List<ROI> ROIs, MaskAction maskAction, double maskValue, CombineMode combineMode) throws ROIException Use the suppliedROI
s in the slice to mask the image. Masking is the process of setting some of the pixel values to themaskValue
according to whether they are inside or outside the ROIs. Before the mask action is applied, theROI
s are combined acording to thecombineMode
.- Parameters:
slice
- the slice of the image to be masked.ROIs
- aList
ofROI
s to be used as a mask.maskAction
- one of:- MaskAction.NONE - no masking is performed;
- MaskAction.MASK_INSIDE - pixels inside the
ROI
s are set to the mask value; - MaskAction.MASK_OUTSIDE - pixels outside the
ROI
s are set to the mask value. - MaskAction.MASK_INSIDE_SOFT - pixels inside the
ROI
s are set to somewhere between the mask value and the original pixel value depending how much of each pixel is inside theROI
s; - MaskAction.MASK_OUTSIDE_SOFT - pixels outside the
ROI
s are set to somewhere between the mask value and the original pixel value depending how much of each pixel is inside theROI
s.
maskValue
- the value to which pixel intensities will be changed. If maskValue is non-integer, then its value will be rounded to the nearest integer for Integer pixel value types. If the maskValue is outside the dynamic range of the pixel value type, then it will be truncated.combineMode
- governs the way in which multipleROI
s are combined before the mask is applied. One of:CombineMode.UNION
- a region is formed which is the union of all selectedROI
s;CombineMode.INTERSECTION
- a region is formed which is the intersection of all selectedROI
s;CombineMode.XOR
- a region is formed which is the exclsive OR of all selectedROI
s.- Throws:
ROIException
- if there is no current displayed image or if the displayed image doesn't have a slice selected, or if the selected slice has noROI
s.
-
unloadROIs
boolean unloadROIs()Unload allROI
s from the frame.- Returns:
- true if the
ROI
s were successfully unloaded.
-
unloadROIs
boolean unloadROIs(boolean noQuery) Unload allROI
s from the frame, optionally unloading without querying the user.- Parameters:
noQuery
- iftrue
, the ROIs will be unloaded without querying the user.- Returns:
- true if the
ROI
s were successfully unloaded.
-
unloadROIs
Unload allROI
s from theCanAddROIToFrame
, optionally unloading without querying the user.- Parameters:
c
- the component used as the parent of anyJOptionPane
used to query the user.noQuery
- iftrue
, the ROIs will be unloaded without querying the user.- Returns:
true
if theROI
s were successfully unloaded.
-
unloadROIs
Unload the suppliedROI
s from theCanAddROIToFrame
, optionally unloading without querying the user.- Parameters:
roisToUnload
- aList<ROI>
of the ROIs to unload.c
- the component used as the parent of anyJOptionPane
used to query the user.noQuery
- iftrue
, the ROIs will be unloaded without querying the user.- Returns:
true
if theROI
s were successfully unloaded.
-
showROIToolkit
void showROIToolkit()Show the tool that is used to interactively create, modify and deleteROI
s. -
showError
Shows an error message in theCanAddROIToFrame
.- Parameters:
message
- the error message to show.
-
showStatus
Shows a status message in theCanAddROIToFrame
.- Parameters:
message
- the status message to show.
-