Class Montage

Object
AnchorBean<Task<StackSequenceInput, MontageSharedState>>
Task<StackSequenceInput, MontageSharedState>
Montage

public class Montage extends Task<StackSequenceInput, MontageSharedState>
Creates a montage of images, by tiling them side-by-side.

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 imageMetadataReader which is often much quicker than opening an image with the stackReader but 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 NameDefault?Description
"unlabelled"yesThe montage of all the input images - without a label indicating the identifier of each image.
"labelled"yesThe 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
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    afterAllJobsAreExecuted(MontageSharedState sharedState, InputOutputContext context)
     
    beforeAnyJobIsExecuted(Outputter outputter, ConcurrencyPlan concurrencyPlan, List<StackSequenceInput> inputs, ParametersExperiment parameters)
     
    OutputEnabledMutable
     
    void
    doJobOnInput(InputBound<StackSequenceInput, MontageSharedState> input)
     
    BoxAligner
    When varyImageSize==false and varyImageLocation==false, how to align a smaller image inside a larger cell.
    BoxAligner
    When label==false and varyImageLocation==false, how to align the label with its associated image.
    StackDisplayer
    How to convert an image to be displayed to the user.
    ScaleCalculator
    How to calculate the size of each image, when varyImageSize==false.
    ImageMetadataReader
    How to read the ImageMetadata from the file-system.
    Interpolator
    How to resize images.
    double
    When label==true, this determines the height of the label.
    double
    An ideal approximate ratio of the number of rows to the number of columns.
    StackReader
    Fallback for imageMetadataReader to read image files without a directy metadata reader.
    int
    If no specific width or scaling-factor is suggested, this determines the default width that the combined-montage should have, when varyImageSize==true.
    double
    If no specific width or scaling-factor is suggested, this determines the default percentage of the existing size, the combined-montage should have, when varyImageSize==true.
    boolean
     
    InputTypesExpected
     
    boolean
    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.
    boolean
    When true, the images may vary in width/height in their respective rows to fill space, while preserving the aspect-ratio of each image.
    void
    setAligner(BoxAligner aligner)
    When varyImageSize==false and varyImageLocation==false, how to align a smaller image inside a larger cell.
    void
    setAlignerLabel(BoxAligner alignerLabel)
    When label==false and varyImageLocation==false, how to align the label with its associated image.
    void
    setDisplayer(StackDisplayer displayer)
    How to convert an image to be displayed to the user.
    void
    setFixedSizeScaler(ScaleCalculator fixedSizeScaler)
    How to calculate the size of each image, when varyImageSize==false.
    void
    setImageMetadataReader(ImageMetadataReader imageMetadataReader)
    How to read the ImageMetadata from the file-system.
    void
    setInterpolator(Interpolator interpolator)
    How to resize images.
    void
    setRatioHeightForLabel(double ratioHeightForLabel)
    When label==true, this determines the height of the label.
    void
    setRatioRowsToColumns(double ratioRowsToColumns)
    An ideal approximate ratio of the number of rows to the number of columns.
    void
    setStackReader(StackReader stackReader)
    Fallback for imageMetadataReader to read image files without a directy metadata reader.
    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.
    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.
    void
    setVaryingSizeWidth(int varyingSizeWidth)
    If no specific width or scaling-factor is suggested, this determines the default width that the combined-montage should have, when varyImageSize==true.
    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, when varyImageSize==true.

    Methods inherited from class org.anchoranalysis.experiment.bean.task.Task

    executeJob, isInputCompatibleWith

    Methods inherited from class org.anchoranalysis.bean.AnchorBean

    checkMisconfigured, describeBean, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Montage

      public Montage()
  • Method Details

    • beforeAnyJobIsExecuted

      public MontageSharedState beforeAnyJobIsExecuted(Outputter outputter, ConcurrencyPlan concurrencyPlan, List<StackSequenceInput> inputs, ParametersExperiment parameters) throws ExperimentExecutionException
      Specified by:
      beforeAnyJobIsExecuted in class Task<StackSequenceInput, MontageSharedState>
      Throws:
      ExperimentExecutionException
    • doJobOnInput

      public void doJobOnInput(InputBound<StackSequenceInput, MontageSharedState> input) throws JobExecutionException
      Specified by:
      doJobOnInput in class Task<StackSequenceInput, MontageSharedState>
      Throws:
      JobExecutionException
    • afterAllJobsAreExecuted

      public void afterAllJobsAreExecuted(MontageSharedState sharedState, InputOutputContext context) throws ExperimentExecutionException
      Specified by:
      afterAllJobsAreExecuted in class Task<StackSequenceInput, MontageSharedState>
      Throws:
      ExperimentExecutionException
    • inputTypesExpected

      public InputTypesExpected inputTypesExpected()
      Specified by:
      inputTypesExpected in class Task<StackSequenceInput, MontageSharedState>
    • hasVeryQuickPerInputExecution

      public boolean hasVeryQuickPerInputExecution()
      Specified by:
      hasVeryQuickPerInputExecution in class Task<StackSequenceInput, MontageSharedState>
    • defaultOutputs

      public OutputEnabledMutable defaultOutputs()
      Overrides:
      defaultOutputs in class Task<StackSequenceInput, MontageSharedState>
    • getImageMetadataReader

      public ImageMetadataReader getImageMetadataReader()
      How to read the ImageMetadata from the file-system.
    • setImageMetadataReader

      public void setImageMetadataReader(ImageMetadataReader imageMetadataReader)
      How to read the ImageMetadata from the file-system.
    • getStackReader

      public StackReader getStackReader()
      Fallback for imageMetadataReader to read image files without a directy metadata reader.
    • setStackReader

      public void setStackReader(StackReader stackReader)
      Fallback for imageMetadataReader to 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, varyImageSize will always be considered also as true.

    • 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, varyImageSize will always be considered also as true.

    • getAligner

      public BoxAligner getAligner()
      When varyImageSize==false and varyImageLocation==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)
      When varyImageSize==false and varyImageLocation==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()
      When label==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.05 i.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)
      When label==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.05 i.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()
      When label==false and varyImageLocation==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)
      When label==false and varyImageLocation==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, when varyImageSize==false.

      Otherwise, it is irrelevant.

    • setFixedSizeScaler

      public void setFixedSizeScaler(ScaleCalculator fixedSizeScaler)
      How to calculate the size of each image, when varyImageSize==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, when varyImageSize==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, when varyImageSize==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, when varyImageSize==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, when varyImageSize==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 ratio number_rows / number_columns.

      When < 1.0, then the algorithm tries to have more columns than rows, to match the ratio number_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 ratio number_rows / number_columns.

      When < 1.0, then the algorithm tries to have more columns than rows, to match the ratio number_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.