Class Montage
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidafterAllJobsAreExecuted(MontageSharedState sharedState, InputOutputContext context) beforeAnyJobIsExecuted(Outputter outputter, ConcurrencyPlan concurrencyPlan, List<StackSequenceInput> inputs, ParametersExperiment parameters) OutputEnabledMutablevoiddoJobOnInput(InputBound<StackSequenceInput, MontageSharedState> input) BoxAlignerWhenvaryImageSize==falseandvaryImageLocation==false, how to align a smaller image inside a larger cell.BoxAlignerWhenlabel==falseandvaryImageLocation==false, how to align the label with its associated image.StackDisplayerHow to convert an image to be displayed to the user.ScaleCalculatorHow to calculate the size of each image, whenvaryImageSize==false.ImageMetadataReaderHow to read theImageMetadatafrom the file-system.InterpolatorHow to resize images.doubleWhenlabel==true, this determines the height of the label.doubleAn ideal approximate ratio of the number of rows to the number of columns.StackReaderFallback forimageMetadataReaderto read image files without a directy metadata reader.intIf no specific width or scaling-factor is suggested, this determines the default width that the combined-montage should have, whenvaryImageSize==true.doubleIf no specific width or scaling-factor is suggested, this determines the default percentage of the existing size, the combined-montage should have, whenvaryImageSize==true.booleanInputTypesExpectedbooleanWhen 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.booleanWhen true, the images may vary in width/height in their respective rows to fill space, while preserving the aspect-ratio of each image.voidsetAligner(BoxAligner aligner) WhenvaryImageSize==falseandvaryImageLocation==false, how to align a smaller image inside a larger cell.voidsetAlignerLabel(BoxAligner alignerLabel) Whenlabel==falseandvaryImageLocation==false, how to align the label with its associated image.voidsetDisplayer(StackDisplayer displayer) How to convert an image to be displayed to the user.voidsetFixedSizeScaler(ScaleCalculator fixedSizeScaler) How to calculate the size of each image, whenvaryImageSize==false.voidsetImageMetadataReader(ImageMetadataReader imageMetadataReader) How to read theImageMetadatafrom the file-system.voidsetInterpolator(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(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, isInputCompatibleWithMethods inherited from class org.anchoranalysis.bean.AnchorBean
checkMisconfigured, describeBean, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString
-
Constructor Details
-
Montage
public Montage()
-
-
Method Details
-
beforeAnyJobIsExecuted
public MontageSharedState beforeAnyJobIsExecuted(Outputter outputter, ConcurrencyPlan concurrencyPlan, List<StackSequenceInput> inputs, ParametersExperiment parameters) throws ExperimentExecutionException - Specified by:
beforeAnyJobIsExecutedin classTask<StackSequenceInput, MontageSharedState>- Throws:
ExperimentExecutionException
-
doJobOnInput
public void doJobOnInput(InputBound<StackSequenceInput, MontageSharedState> input) throws JobExecutionException - Specified by:
doJobOnInputin classTask<StackSequenceInput, MontageSharedState>- Throws:
JobExecutionException
-
inputTypesExpected
public InputTypesExpected inputTypesExpected()- Specified by:
inputTypesExpectedin classTask<StackSequenceInput, MontageSharedState>
-
hasVeryQuickPerInputExecution
public boolean hasVeryQuickPerInputExecution()- Specified by:
hasVeryQuickPerInputExecutionin classTask<StackSequenceInput, MontageSharedState>
-
defaultOutputs
public OutputEnabledMutable defaultOutputs()- Overrides:
defaultOutputsin classTask<StackSequenceInput, MontageSharedState>
-
getImageMetadataReader
public ImageMetadataReader getImageMetadataReader()How to read theImageMetadatafrom the file-system. -
setImageMetadataReader
public void setImageMetadataReader(ImageMetadataReader imageMetadataReader) How to read theImageMetadatafrom the file-system. -
getStackReader
public StackReader getStackReader()Fallback forimageMetadataReaderto read image files without a directy metadata reader. -
setStackReader
public void setStackReader(StackReader stackReader) Fallback forimageMetadataReaderto read image files without a directy metadata reader. -
getInterpolator
public Interpolator getInterpolator()How to resize images. -
setInterpolator
public void setInterpolator(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 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(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 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(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 ScaleCalculator getFixedSizeScaler()How to calculate the size of each image, whenvaryImageSize==false.Otherwise, it is irrelevant.
-
setFixedSizeScaler
public void setFixedSizeScaler(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 StackDisplayer getDisplayer()How to convert an image to be displayed to the user. -
setDisplayer
public void setDisplayer(StackDisplayer displayer) How to convert an image to be displayed to the user.
-