Class Fill
public class Fill extends StackArranger
Extents together to completely fill the available space, while preserving aspect
ratio.
Inspired by this Python
implementation by Jesse Crocker, which is in turn apparently inspired originally from
https://www.crispymtn.com/stories/the-algorithm-for-a-perfectly-balanced-photo-gallery
collage.py.
- Author:
- Owen Feehan
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description StackArrangementarrangeStacks(Iterator<org.anchoranalysis.spatial.box.Extent> extents, OperationContext context)Arranges stacks to that they fit together in a single raster.voidcheckMisconfigured(BeanInstanceMap defaultInstances)intgetNumberRows()The number of rows to use the montage, when sufficient images are available.intgetWidth()The width of the combined image in pixels.doublegetWidthRatio()What fraction of the natural width of the elements should be used to determine the final width.booleanisVaryNumberImagesPerRow()When true the number ofExtents per row is allowed vary, to sensibly fill space.voidsetNumberRows(int numberRows)The number of rows to use the montage, when sufficient images are available.voidsetVaryNumberImagesPerRow(boolean varyNumberImagesPerRow)When true the number ofExtents per row is allowed vary, to sensibly fill space.voidsetWidth(int width)The width of the combined image in pixels.voidsetWidthRatio(double widthRatio)What fraction of the natural width of the elements should be used to determine the final width.Methods inherited from class org.anchoranalysis.image.bean.spatial.arrange.StackArranger
combine, combineMethods inherited from class org.anchoranalysis.bean.AnchorBean
describeBean, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString
-
Constructor Details
-
Method Details
-
checkMisconfigured
- Overrides:
checkMisconfiguredin classAnchorBean<StackArranger>- Throws:
BeanMisconfiguredException
-
arrangeStacks
public StackArrangement arrangeStacks(Iterator<org.anchoranalysis.spatial.box.Extent> extents, OperationContext context) throws ArrangeStackExceptionDescription copied from class:StackArrangerArranges stacks to that they fit together in a single raster.- Specified by:
arrangeStacksin classStackArranger- Parameters:
extents- the size of each respective stack for the arrangement.context- objects for the operation.- Returns:
- bounding-boxes for each respective
RGBStackin the unified plane. - Throws:
ArrangeStackException- if a bounding-box cannot be determined for any stack.
-
getNumberRows
public int getNumberRows()The number of rows to use the montage, when sufficient images are available.If fewer
Extents are passed, then a row is created for eachExtent, so much as possible. -
setNumberRows
public void setNumberRows(int numberRows)The number of rows to use the montage, when sufficient images are available.If fewer
Extents are passed, then a row is created for eachExtent, so much as possible. -
isVaryNumberImagesPerRow
public boolean isVaryNumberImagesPerRow()When true the number ofExtents per row is allowed vary, to sensibly fill space.When false, the total number of
Extents per row is kept uniform, apart from the final occupied row (if there are insufficient images to fully populate it).In both cases, the sizes of the images are allowed to vary, to maximally fill the available space.
-
setVaryNumberImagesPerRow
public void setVaryNumberImagesPerRow(boolean varyNumberImagesPerRow)When true the number ofExtents per row is allowed vary, to sensibly fill space.When false, the total number of
Extents per row is kept uniform, apart from the final occupied row (if there are insufficient images to fully populate it).In both cases, the sizes of the images are allowed to vary, to maximally fill the available space.
-
getWidth
public int getWidth()The width of the combined image in pixels.When 0, this is disabled.
At least one of both
widthandwidthRatiomust be enabled. If both are, the minimum width is used. -
setWidth
public void setWidth(int width)The width of the combined image in pixels.When 0, this is disabled.
At least one of both
widthandwidthRatiomust be enabled. If both are, the minimum width is used. -
getWidthRatio
public double getWidthRatio()What fraction of the natural width of the elements should be used to determine the final width.The natural width of the elements, is the average-width of an entire row after partitioning.
When 0.0, this is disabled.
At least one of both
widthandwidthRatiomust be enabled. If both are, the minimum width is used. -
setWidthRatio
public void setWidthRatio(double widthRatio)What fraction of the natural width of the elements should be used to determine the final width.The natural width of the elements, is the average-width of an entire row after partitioning.
When 0.0, this is disabled.
At least one of both
widthandwidthRatiomust be enabled. If both are, the minimum width is used.
-