Class RoiLabeling
This enables switching between different methods of representing regions as required.
 Note that in v0.6.0 IJProcessing was introduced as the main class for working with Rois and labeled images.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidclearOutside(ImageProcessor ip, Roi roi) Clear (i.e.static voidFill holes in a binary image.static voidfillOutside(ImageProcessor ip, Roi roi, double value) Fill in a region outside a specified ROIstatic ByteProcessorCreate a binary image for pixels that have a higher value than their neighbors.static ByteProcessorCreate a binary image for pixels that have a lower value than their neighbors.static List<PolygonRoi> getFilledPolygonROIs(ImageProcessor ip, int wandMode) Get filled PolygonRois for connected pixels with the same value in an image.static Map<Float, PolygonRoi> getFilledPolygonROIsFromLabels(ImageProcessor ip, int wandMode) Get filled Polygon ROIs using distinct labels, creating a map between labels and ROIs.static ImageProcessorlabelImage(ImageProcessor ip, float threshold, boolean conn8) Create a labelled image from above-threshold pixels for an image.static ImageProcessorlabelROIs(ImageProcessor ipLabels, List<? extends Roi> rois) Label ROIs by filling each pixel with an integer value corresponding to the index of the Roi in the list + 1.static Roi[]labelsToConnectedROIs(ImageProcessor ipLabels, int n) Deprecated.static List<PolygonRoi> labelsToFilledRoiList(ImageProcessor ipLabels, boolean conn8) Convert a labelled image into a list of PolygonRois by tracing.static PolygonRoi[]labelsToFilledROIs(ImageProcessor ipLabels, int n) Convert a labelled image into a list of PolygonRois by tracing.static intremoveByAreas(ByteProcessor bp, double minPixels, double maxPixels, boolean conn8) Remove objects containing < minPixels or > maxPixels.static voidremoveSmallAreas(ByteProcessor bp, double minPixels, boolean conn8) Remove objects having small areas, defined in terms of pixelsstatic PolygonRoiDeprecated.since v0.6.0; useIJProcessing.wandToRoi(Wand)instead.
- 
Constructor Details- 
RoiLabelingpublic RoiLabeling()
 
- 
- 
Method Details- 
findDirectionalMaximaCreate a binary image for pixels that have a higher value than their neighbors. Comparisons are made horizontally, vertically and diagonally. Pixels meeting the criterion have the value 255, all others are 0.- Parameters:
- ip-
- Returns:
 
- 
findDirectionalMinimaCreate a binary image for pixels that have a lower value than their neighbors. Comparisons are made horizontally, vertically and diagonally. Pixels meeting the criterion have the value 255, all others are 0.- Parameters:
- ip-
- Returns:
 
- 
labelsToFilledROIsConvert a labelled image into a list of PolygonRois by tracing.Note that labels are assumed not to contain any holes or nested ROIs; ROIs produced by this command will not contain holes. Some entries in the resulting array may be null if this is not the case, or if not all labels are found. Otherwise, pixels with the integer label L will belong to the Roi in the output array at entry L-1 - Parameters:
- ipLabels-
- n- maximum number of labels
- Returns:
 
- 
labelsToFilledRoiListConvert a labelled image into a list of PolygonRois by tracing.Unlike labelsToFilledROIs, the order in which ROIs are returned is arbitrary. Also, the multiple Rois may be created for the same label, if unconnected regions are used. - Parameters:
- ipLabels-
- conn8-
- Returns:
 
- 
getFilledPolygonROIsFromLabelsGet filled Polygon ROIs using distinct labels, creating a map between labels and ROIs.Note that discontinuous ROIs are not supported; if labelled regions are discontinuous, then ROIs detected earlier will be discarded from the map. - Parameters:
- ip-
- wandMode-
- Returns:
 
- 
getFilledPolygonROIsGet filled PolygonRois for connected pixels with the same value in an image. Because this uses ImageJ's Wand tool, holes will be filled.Note that this command applies any thresholds that were set in the ImageProcessor, returning only Rois for values within these limits. Therefore to identify only non-zero pixels in a labelled image you may need to first call ip.setThreshold(0.5, Double.POSITIVE_INFINITY, ImageProcessor.NO_LUT_UPDATE);- Parameters:
- ip-
- wandMode-
- Returns:
 
- 
wandToRoiDeprecated.since v0.6.0; useIJProcessing.wandToRoi(Wand)instead.Convert a traced outline from the ImageJ Wand into a PolygonRoi.- Parameters:
- wand-
- Returns:
 
- 
fillHolesFill holes in a binary image.Assumes 255 is foreground, 0 is background. Based on code in ImageJ's Binary class. - Parameters:
- bp-
 
- 
labelROIsLabel ROIs by filling each pixel with an integer value corresponding to the index of the Roi in the list + 1.- Parameters:
- ipLabels-
- rois-
- Returns:
 
- 
labelImageCreate a labelled image from above-threshold pixels for an image.- Parameters:
- ip-
- threshold-
- conn8-
- Returns:
- labelled image, as a ShortProcessor (if possible) or FloatProcessor (if necessary)
 
- 
labelsToConnectedROIsDeprecated.since v0.6.0; useIJProcessing.labelsToRoisArray(ImageProcessor)orIJProcessing.labelsToRois(ImageProcessor)instead.Create ROIs from labels in an image.- Parameters:
- ipLabels- the labeled image; generally this should be a ByteProcessor or ShortProcessor
- n- the total number of labels; often this is equal to the maximum value in the image
- Returns:
- an array of length n; output[i] is the ROI for label i+1, or null if no Roi is found with that label.
 
- 
removeSmallAreasRemove objects having small areas, defined in terms of pixels- Parameters:
- bp-
- minPixels- minimum number of pixels in an object that should be kept
- conn8-
 
- 
removeByAreaspublic static int removeByAreas(ByteProcessor bp, double minPixels, double maxPixels, boolean conn8) Remove objects containing < minPixels or > maxPixels.- Parameters:
- bp-
- minPixels-
- maxPixels-
- conn8-
- Returns:
- the number of connected objects remaining.
 
- 
fillOutsideFill in a region outside a specified ROI- Parameters:
- ip-
- roi-
- value-
 
- 
clearOutsideClear (i.e. set pixels to zero) in a region outside a specified ROI- Parameters:
- ip-
- roi-
 
 
- 
IJProcessing.labelsToRoisArray(ImageProcessor)orIJProcessing.labelsToRois(ImageProcessor)instead.