Class OutlinePreserveRelativeSize


public class OutlinePreserveRelativeSize extends ThumbnailFromObjects
Create a thumbnail by drawing an outline of an object at a particular-scale, and placing it centered in a window of a certain size.

Preserves the relative-size between objects (i.e. they are all reduced by the same scale-factor) in the same batch.

If it's a z-stack, a maximum intensity projection is first applied.

All thumbnails are created with identical size. An error will occur if the background is ever smaller than the thumbnail size.

If no specific background-channel is set with setBackgroundChannelIndex(int) then the following scheme applies:

  • If backgroundSource has exactly zero channels, an empty zero-valued monochrome background is used (unsigned 8 bit).
  • If backgroundSource has exactly one channel, it's used as a monochrome background
  • If backgroundSource has exactly three channels, it's used as a RGB background
  • If backgroundSource has any other number of channels, the first channel is used as a background.
Author:
Owen Feehan
  • Constructor Details

    • OutlinePreserveRelativeSize

      public OutlinePreserveRelativeSize()
  • Method Details

    • createToColorUnselectedObjects

      public static OutlinePreserveRelativeSize createToColorUnselectedObjects(Interpolator interpolator)
      Alternative constructor that switches on the coloring of unselected objects by default.

      They are colored in blue.

      Parameters:
      interpolator - how to resize an image.
      Returns:
      a newly created instance of OutlinePreserveRelativeSize that colors unselected objects, but otherwise uses defaults.
    • start

      public ThumbnailBatch<ObjectCollection> start(ObjectCollection objects, StreamableCollection<BoundingBox> boundingBoxes, Optional<Stack> backgroundSource, ExecutionTimeRecorder executionTimeRecorder) throws OperationFailedException
      Description copied from class: ThumbnailFromObjects
      Initializes a batch to create thumbnails.

      A batch is a set of objects which are calibrated together (to have the same scale etc.)

      Specified by:
      start in class ThumbnailFromObjects
      Parameters:
      objects - the entire set of objects in the batch (for which thumbnails may be subsequently created)
      boundingBoxes - bounding-boxes that minimally enclose all the inputs to feature rows (e.g. a pair of objects or a single-object) and can be used for guessing scale-factors. A supplier is used as the stream may be desired multiple times.
      backgroundSource - a stack that will be used to form the background (or some part of may be used)
      executionTimeRecorder - records execution time for various operations
      Returns:
      a ThumbnailBatch interface to create thumbnails for individual objects
      Throws:
      OperationFailedException - if the batch initialization fails
    • getSize

      public SizeXY getSize()
      Size of all created thumbnails
    • setSize

      public void setSize(SizeXY size)
      Size of all created thumbnails
    • getBackgroundChannelIndex

      public int getBackgroundChannelIndex()
      Uses only this channel (identified by an index in the stack) as the background, -1 disables.
    • setBackgroundChannelIndex

      public void setBackgroundChannelIndex(int backgroundChannelIndex)
      Uses only this channel (identified by an index in the stack) as the background, -1 disables.
    • getInterpolator

      public Interpolator getInterpolator()
      Interpolator used when scaling the background
    • setInterpolator

      public void setInterpolator(Interpolator interpolator)
      Interpolator used when scaling the background
    • getOutlineWidth

      public int getOutlineWidth()
      The width of the outline. By default, it's 3 as it's nice to have a strongly easily-visible emphasis on where the object is in a thumbnail.
    • setOutlineWidth

      public void setOutlineWidth(int outlineWidth)
      The width of the outline. By default, it's 3 as it's nice to have a strongly easily-visible emphasis on where the object is in a thumbnail.
    • getColorUnselectedObjects

      public RGBColorBean getColorUnselectedObjects()
      Optionally outline the other (unselected for the thumbnail) objects in this particular color. If not set, these objects aren't outlined at all.
    • setColorUnselectedObjects

      public void setColorUnselectedObjects(RGBColorBean colorUnselectedObjects)
      Optionally outline the other (unselected for the thumbnail) objects in this particular color. If not set, these objects aren't outlined at all.
    • isOverlappingObjects

      public boolean isOverlappingObjects()
      Whether objects may overlap or not when unscaled.

      If they overlap, we scale them individually, not taking account of their neighbours.

      If they may not overlap, we scale them collectively, as visually this gives tighter borders between neighbouring objects.

    • setOverlappingObjects

      public void setOverlappingObjects(boolean overlappingObjects)
      Whether objects may overlap or not when unscaled.

      If they overlap, we scale them individually, not taking account of their neighbours.

      If they may not overlap, we scale them collectively, as visually this gives tighter borders between neighbouring objects.

    • getDisplayer

      public StackDisplayer getDisplayer()
      How to convert an image so that it can be displayed.
    • setDisplayer

      public void setDisplayer(StackDisplayer displayer)
      How to convert an image so that it can be displayed.