Class Montage
public class Montage extends org.anchoranalysis.experiment.bean.task.Task<org.anchoranalysis.image.io.stack.input.StackSequenceInput,MontageSharedState>
The images are tiled into a grid formation, to have a approximately similar number of rows and columns.
The size of the montage is determined by two factors, varyImageSize and an optional
suggestion on size.
When varyImageSize==false, by default each image will be scaled to approximately
600x480, preserving aspect ratio, as per fixedSizeScaler. However, a size suggestion in
the form of a uniform scaling constant, will override this, and be applied instead to each image.
Other size suggestions are disallowed.
When varyImageSize==true, by default the combined image will have the larger of
varyingSizeWidth and varyingSizeWidthRatio (as calculated against the average row-size).
However, suggestions offering a fixed-width (but no height should be specified), or a constant
scaling-factor will override this. Other size suggestions are disallowed.
Any 3D images are flattened into a 2D image using a maximum-intensity projection.
The montage occurs in a two step process:
- Sequentially, the metadata of all images is initially read, so that widths and
heights are known, and an arrangement can be determined. This occurs through the
imageMetadataReaderwhich is often much quicker than opening an image with thestackReaderbut this is not always the case. - Then in parallel each image is read from the file-system and added to the combined image.
If a particular image is errored during the first step, it is omitted from the montage entirely, and an error will register with its respective job in the second step.
If a particular image succeeds in the first step, but fails in the second step, an error will register with the respective job, and its place on the montage will be entirely black - apart from a label of background red color, if labelling is enabled.
The following outputs are produced:
| Output Name | Default? | Description |
|---|---|---|
| "unlabelled" | yes | The montage of all the input images - without a label indicating the identifier of each image. |
| "labelled" | yes | The montage of all the input images - with a label indicating the identifier of each image. |
inherited from Task |
- Author:
- Owen Feehan
-
Constructor Summary
Constructors Constructor Description Montage() -
Method Summary
Modifier and Type Method Description voidafterAllJobsAreExecuted(MontageSharedState sharedState, org.anchoranalysis.io.output.outputter.InputOutputContext context)MontageSharedStatebeforeAnyJobIsExecuted(org.anchoranalysis.io.output.outputter.Outputter outputter, org.anchoranalysis.inference.concurrency.ConcurrencyPlan concurrencyPlan, List<org.anchoranalysis.image.io.stack.input.StackSequenceInput> inputs, org.anchoranalysis.experiment.task.ParametersExperiment parameters)org.anchoranalysis.io.output.enabled.OutputEnabledMutabledefaultOutputs()voiddoJobOnInput(org.anchoranalysis.experiment.task.InputBound<org.anchoranalysis.image.io.stack.input.StackSequenceInput,MontageSharedState> input)org.anchoranalysis.image.bean.spatial.arrange.align.BoxAlignergetAligner()WhenvaryImageSize==falseandvaryImageLocation==false, how to align a smaller image inside a larger cell.org.anchoranalysis.image.bean.spatial.arrange.align.BoxAlignergetAlignerLabel()Whenlabel==falseandvaryImageLocation==false, how to align the label with its associated image.org.anchoranalysis.image.bean.displayer.StackDisplayergetDisplayer()How to convert an image to be displayed to the user.org.anchoranalysis.image.bean.spatial.ScaleCalculatorgetFixedSizeScaler()How to calculate the size of each image, whenvaryImageSize==false.org.anchoranalysis.image.io.bean.stack.metadata.reader.ImageMetadataReadergetImageMetadataReader()How to read theImageMetadatafrom the file-system.org.anchoranalysis.image.bean.interpolator.InterpolatorgetInterpolator()How to resize images.doublegetRatioHeightForLabel()Whenlabel==true, this determines the height of the label.doublegetRatioRowsToColumns()An ideal approximate ratio of the number of rows to the number of columns.org.anchoranalysis.image.io.bean.stack.reader.StackReadergetStackReader()Fallback forimageMetadataReaderto read image files without a directy metadata reader.intgetVaryingSizeWidth()If no specific width or scaling-factor is suggested, this determines the default width that the combined-montage should have, whenvaryImageSize==true.doublegetVaryingSizeWidthRatio()If no specific width or scaling-factor is suggested, this determines the default percentage of the existing size, the combined-montage should have, whenvaryImageSize==true.booleanhasVeryQuickPerInputExecution()org.anchoranalysis.experiment.task.InputTypesExpectedinputTypesExpected()booleanisVaryImageLocation()When true, the location of an image in the grid, as well as the number of images in each row are both allowed to vary to fill space.booleanisVaryImageSize()When true, the images may vary in width/height in their respective rows to fill space, while preserving the aspect-ratio of each image.voidsetAligner(org.anchoranalysis.image.bean.spatial.arrange.align.BoxAligner aligner)WhenvaryImageSize==falseandvaryImageLocation==false, how to align a smaller image inside a larger cell.voidsetAlignerLabel(org.anchoranalysis.image.bean.spatial.arrange.align.BoxAligner alignerLabel)Whenlabel==falseandvaryImageLocation==false, how to align the label with its associated image.voidsetDisplayer(org.anchoranalysis.image.bean.displayer.StackDisplayer displayer)How to convert an image to be displayed to the user.voidsetFixedSizeScaler(org.anchoranalysis.image.bean.spatial.ScaleCalculator fixedSizeScaler)How to calculate the size of each image, whenvaryImageSize==false.voidsetImageMetadataReader(org.anchoranalysis.image.io.bean.stack.metadata.reader.ImageMetadataReader imageMetadataReader)How to read theImageMetadatafrom the file-system.voidsetInterpolator(org.anchoranalysis.image.bean.interpolator.Interpolator interpolator)How to resize images.voidsetRatioHeightForLabel(double ratioHeightForLabel)Whenlabel==true, this determines the height of the label.voidsetRatioRowsToColumns(double ratioRowsToColumns)An ideal approximate ratio of the number of rows to the number of columns.voidsetStackReader(org.anchoranalysis.image.io.bean.stack.reader.StackReader stackReader)Fallback forimageMetadataReaderto read image files without a directy metadata reader.voidsetVaryImageLocation(boolean varyImageLocation)When true, the location of an image in the grid, as well as the number of images in each row are both allowed to vary to fill space.voidsetVaryImageSize(boolean varyImageSize)When true, the images may vary in width/height in their respective rows to fill space, while preserving the aspect-ratio of each image.voidsetVaryingSizeWidth(int varyingSizeWidth)If no specific width or scaling-factor is suggested, this determines the default width that the combined-montage should have, whenvaryImageSize==true.voidsetVaryingSizeWidthRatio(double varyingSizeWidthRatio)If no specific width or scaling-factor is suggested, this determines the default percentage of the existing size, the combined-montage should have, whenvaryImageSize==true.Methods inherited from class org.anchoranalysis.experiment.bean.task.Task
executeJob, isInputCompatibleWith
-
Constructor Details
-
Montage
public Montage()
-
-
Method Details
-
beforeAnyJobIsExecuted
public MontageSharedState beforeAnyJobIsExecuted(org.anchoranalysis.io.output.outputter.Outputter outputter, org.anchoranalysis.inference.concurrency.ConcurrencyPlan concurrencyPlan, List<org.anchoranalysis.image.io.stack.input.StackSequenceInput> inputs, org.anchoranalysis.experiment.task.ParametersExperiment parameters) throws org.anchoranalysis.experiment.ExperimentExecutionException- Specified by:
beforeAnyJobIsExecutedin classorg.anchoranalysis.experiment.bean.task.Task<org.anchoranalysis.image.io.stack.input.StackSequenceInput,MontageSharedState>- Throws:
org.anchoranalysis.experiment.ExperimentExecutionException
-
doJobOnInput
public void doJobOnInput(org.anchoranalysis.experiment.task.InputBound<org.anchoranalysis.image.io.stack.input.StackSequenceInput,MontageSharedState> input) throws org.anchoranalysis.experiment.JobExecutionException- Specified by:
doJobOnInputin classorg.anchoranalysis.experiment.bean.task.Task<org.anchoranalysis.image.io.stack.input.StackSequenceInput,MontageSharedState>- Throws:
org.anchoranalysis.experiment.JobExecutionException
-
afterAllJobsAreExecuted
public void afterAllJobsAreExecuted(MontageSharedState sharedState, org.anchoranalysis.io.output.outputter.InputOutputContext context) throws org.anchoranalysis.experiment.ExperimentExecutionException- Specified by:
afterAllJobsAreExecutedin classorg.anchoranalysis.experiment.bean.task.Task<org.anchoranalysis.image.io.stack.input.StackSequenceInput,MontageSharedState>- Throws:
org.anchoranalysis.experiment.ExperimentExecutionException
-
inputTypesExpected
public org.anchoranalysis.experiment.task.InputTypesExpected inputTypesExpected()- Specified by:
inputTypesExpectedin classorg.anchoranalysis.experiment.bean.task.Task<org.anchoranalysis.image.io.stack.input.StackSequenceInput,MontageSharedState>
-
hasVeryQuickPerInputExecution
public boolean hasVeryQuickPerInputExecution()- Specified by:
hasVeryQuickPerInputExecutionin classorg.anchoranalysis.experiment.bean.task.Task<org.anchoranalysis.image.io.stack.input.StackSequenceInput,MontageSharedState>
-
defaultOutputs
public org.anchoranalysis.io.output.enabled.OutputEnabledMutable defaultOutputs()- Overrides:
defaultOutputsin classorg.anchoranalysis.experiment.bean.task.Task<org.anchoranalysis.image.io.stack.input.StackSequenceInput,MontageSharedState>
-
getImageMetadataReader
public org.anchoranalysis.image.io.bean.stack.metadata.reader.ImageMetadataReader getImageMetadataReader()How to read theImageMetadatafrom the file-system. -
setImageMetadataReader
public void setImageMetadataReader(org.anchoranalysis.image.io.bean.stack.metadata.reader.ImageMetadataReader imageMetadataReader)How to read theImageMetadatafrom the file-system. -
getStackReader
public org.anchoranalysis.image.io.bean.stack.reader.StackReader getStackReader()Fallback forimageMetadataReaderto read image files without a directy metadata reader. -
setStackReader
public void setStackReader(org.anchoranalysis.image.io.bean.stack.reader.StackReader stackReader)Fallback forimageMetadataReaderto read image files without a directy metadata reader. -
getInterpolator
public org.anchoranalysis.image.bean.interpolator.Interpolator getInterpolator()How to resize images. -
setInterpolator
public void setInterpolator(org.anchoranalysis.image.bean.interpolator.Interpolator interpolator)How to resize images. -
isVaryImageSize
public boolean isVaryImageSize()When true, the images may vary in width/height in their respective rows to fill space, while preserving the aspect-ratio of each image. -
setVaryImageSize
public void setVaryImageSize(boolean varyImageSize)When true, the images may vary in width/height in their respective rows to fill space, while preserving the aspect-ratio of each image. -
isVaryImageLocation
public boolean isVaryImageLocation()When true, the location of an image in the grid, as well as the number of images in each row are both allowed to vary to fill space.When true,
varyImageSizewill always be considered also astrue. -
setVaryImageLocation
public void setVaryImageLocation(boolean varyImageLocation)When true, the location of an image in the grid, as well as the number of images in each row are both allowed to vary to fill space.When true,
varyImageSizewill always be considered also astrue. -
getAligner
public org.anchoranalysis.image.bean.spatial.arrange.align.BoxAligner getAligner()WhenvaryImageSize==falseandvaryImageLocation==false, how to align a smaller image inside a larger cell. Otherwise ignored.By default, the smaller image grows as much as possible, while preserving the aspect-ratio, but while strictly keeping a tabular form.
-
setAligner
public void setAligner(org.anchoranalysis.image.bean.spatial.arrange.align.BoxAligner aligner)WhenvaryImageSize==falseandvaryImageLocation==false, how to align a smaller image inside a larger cell. Otherwise ignored.By default, the smaller image grows as much as possible, while preserving the aspect-ratio, but while strictly keeping a tabular form.
-
getRatioHeightForLabel
public double getRatioHeightForLabel()Whenlabel==true, this determines the height of the label.Otherwise, it is ignored.
It indicates what portion of the average-image-height (when projected into the image) should the label approximately occupy.
It defaults to
0.05i.e. the label should typically occupy 5% of the average image-height.It can be adjusted to make the label larger or smaller, relative to the image that is being labelled.
Note that a lower minimum exists of label font-size, below which it will not become smaller.
-
setRatioHeightForLabel
public void setRatioHeightForLabel(double ratioHeightForLabel)Whenlabel==true, this determines the height of the label.Otherwise, it is ignored.
It indicates what portion of the average-image-height (when projected into the image) should the label approximately occupy.
It defaults to
0.05i.e. the label should typically occupy 5% of the average image-height.It can be adjusted to make the label larger or smaller, relative to the image that is being labelled.
Note that a lower minimum exists of label font-size, below which it will not become smaller.
-
getAlignerLabel
public org.anchoranalysis.image.bean.spatial.arrange.align.BoxAligner getAlignerLabel()Whenlabel==falseandvaryImageLocation==false, how to align the label with its associated image.By default, it is horizontally-centered at the bottom of the image.
-
setAlignerLabel
public void setAlignerLabel(org.anchoranalysis.image.bean.spatial.arrange.align.BoxAligner alignerLabel)Whenlabel==falseandvaryImageLocation==false, how to align the label with its associated image.By default, it is horizontally-centered at the bottom of the image.
-
getFixedSizeScaler
public org.anchoranalysis.image.bean.spatial.ScaleCalculator getFixedSizeScaler()How to calculate the size of each image, whenvaryImageSize==false.Otherwise, it is irrelevant.
-
setFixedSizeScaler
public void setFixedSizeScaler(org.anchoranalysis.image.bean.spatial.ScaleCalculator fixedSizeScaler)How to calculate the size of each image, whenvaryImageSize==false.Otherwise, it is irrelevant.
-
getVaryingSizeWidth
public int getVaryingSizeWidth()If no specific width or scaling-factor is suggested, this determines the default width that the combined-montage should have, whenvaryImageSize==true.The eventual width will be the maximum of this and the width calculated from
varyingSizeWidthRatio. -
setVaryingSizeWidth
public void setVaryingSizeWidth(int varyingSizeWidth)If no specific width or scaling-factor is suggested, this determines the default width that the combined-montage should have, whenvaryImageSize==true.The eventual width will be the maximum of this and the width calculated from
varyingSizeWidthRatio. -
getVaryingSizeWidthRatio
public double getVaryingSizeWidthRatio()If no specific width or scaling-factor is suggested, this determines the default percentage of the existing size, the combined-montage should have, whenvaryImageSize==true.The eventual width will be the maximum of this and
varyingSizeWidth. -
setVaryingSizeWidthRatio
public void setVaryingSizeWidthRatio(double varyingSizeWidthRatio)If no specific width or scaling-factor is suggested, this determines the default percentage of the existing size, the combined-montage should have, whenvaryImageSize==true.The eventual width will be the maximum of this and
varyingSizeWidth. -
getRatioRowsToColumns
public double getRatioRowsToColumns()An ideal approximate ratio of the number of rows to the number of columns.When
== 1.0, then the algorithm tries to have approximately the same number of rows as columns.When
> 1.0, then the algorithm tries to have more rows than columns, to match the rationumber_rows / number_columns.When
< 1.0, then the algorithm tries to have more columns than rows, to match the rationumber_rows / number_columns. -
setRatioRowsToColumns
public void setRatioRowsToColumns(double ratioRowsToColumns)An ideal approximate ratio of the number of rows to the number of columns.When
== 1.0, then the algorithm tries to have approximately the same number of rows as columns.When
> 1.0, then the algorithm tries to have more rows than columns, to match the rationumber_rows / number_columns.When
< 1.0, then the algorithm tries to have more columns than rows, to match the rationumber_rows / number_columns. -
getDisplayer
public org.anchoranalysis.image.bean.displayer.StackDisplayer getDisplayer()How to convert an image to be displayed to the user. -
setDisplayer
public void setDisplayer(org.anchoranalysis.image.bean.displayer.StackDisplayer displayer)How to convert an image to be displayed to the user.
-