Class ObjectsAsRGBGenerator
- All Implemented Interfaces:
Generator<ObjectCollectionWithProperties>
,TransformingGenerator<ObjectCollectionWithProperties,
,Stack> ElementWriter<ObjectCollectionWithProperties>
- Direct Known Subclasses:
DrawCroppedObjectsGenerator
,DrawObjectsGenerator
public abstract class ObjectsAsRGBGenerator
extends RasterGeneratorSelectFormat<ObjectCollectionWithProperties>
A base class for generators that draw an
ObjectCollection
upon a RGBStack
.- Author:
- Owen Feehan
-
Constructor Summary
ConstructorsConstructorDescriptionObjectsAsRGBGenerator
(DrawObject drawObject, ObjectDrawAttributes attributes, io.vavr.control.Either<Dimensions, DisplayStack> background) Creates a newObjectsAsRGBGenerator
instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected static RGBStack
createEmptyStackFor
(Dimensions dimensions) Creates an emptyRGBStack
.protected abstract RGBStack
generateBackgroundRegion
(ObjectCollectionWithProperties objects, io.vavr.control.Either<Dimensions, DisplayStack> background) Creates aRGBStack
containing the background, without objects being drawn upon it.protected abstract ObjectCollectionWithProperties
Creates aObjectCollectionWithProperties
indicative of the masks that will be imposed on top of the background-region.io.vavr.control.Either
<Dimensions, DisplayStack> A background image or dimensions to define an empty background.Guarantees on the attributes of all images created by the generator.void
setBackground
(io.vavr.control.Either<Dimensions, DisplayStack> background) A background image or dimensions to define an empty background.transform
(ObjectCollectionWithProperties element) Applies any necessary preprocessing to create an element suitable for writing to the filesystem.Methods inherited from class org.anchoranalysis.image.io.stack.output.generator.RasterGeneratorSelectFormat
selectFileExtension, writeToFile
Methods inherited from class org.anchoranalysis.image.io.stack.output.generator.RasterGenerator
write, writeWithIndex
-
Constructor Details
-
ObjectsAsRGBGenerator
public ObjectsAsRGBGenerator(DrawObject drawObject, ObjectDrawAttributes attributes, io.vavr.control.Either<Dimensions, DisplayStack> background) Creates a newObjectsAsRGBGenerator
instance.- Parameters:
drawObject
- Determines how an object is drawn (on the background).attributes
- An association of color and/or other identifies with each object.background
- A background image or dimensions to define an empty background.
-
-
Method Details
-
transform
Description copied from interface:TransformingGenerator
Applies any necessary preprocessing to create an element suitable for writing to the filesystem.- Parameters:
element
- element to be assigned and then transformed.- Returns:
- the transformed element after necessary preprocessing.
- Throws:
OutputWriteFailedException
- if anything goes wrong.
-
guaranteedImageAttributes
Description copied from class:RasterGenerator
Guarantees on the attributes of all images created by the generator.- Specified by:
guaranteedImageAttributes
in classRasterGenerator<ObjectCollectionWithProperties>
- Returns:
- options that are guaranteed to be true of all images by the generator.
-
generateBackgroundRegion
protected abstract RGBStack generateBackgroundRegion(ObjectCollectionWithProperties objects, io.vavr.control.Either<Dimensions, DisplayStack> background) throws CreateExceptionCreates aRGBStack
containing the background, without objects being drawn upon it.This background may be all or only a region of the entire background-stack.
- Parameters:
objects
- the current objects to be drawn.background
- the entire background.- Returns:
- a newly created
RGBStack
, as above. - Throws:
CreateException
- if the background cannot be successfully created.
-
generateMasks
protected abstract ObjectCollectionWithProperties generateMasks(ObjectCollectionWithProperties objects) throws CreateException Creates aObjectCollectionWithProperties
indicative of the masks that will be imposed on top of the background-region.- Parameters:
objects
- the objects to draw.- Returns:
- either
objects
or a derived-representation ofobjects
, as will be drawn on the background-region. - Throws:
CreateException
- if the background cannot be successfully created.
-
createEmptyStackFor
Creates an emptyRGBStack
.Empty implies all voxels are zero-valued i.e. have black color.
- Parameters:
dimensions
- the size of the stack to create.- Returns:
- the newly created
RGBStack
.
-
getBackground
A background image or dimensions to define an empty background. -
setBackground
A background image or dimensions to define an empty background.
-