Class ConvertImageFormat

Object
AnchorBean<Task<NamedChannelsInput, NoSharedState>>
Task<NamedChannelsInput, NoSharedState>
RasterTask<NoSharedState, OutputSequenceIndexed<Stack,String>>
ConvertImageFormat

public class ConvertImageFormat extends RasterTask<NoSharedState, OutputSequenceIndexed<Stack,String>>
Converts each input-image to an output format, optionally changing the bit depth.

Stacks containing multiple series (i.e. multiple images in a single file) are supported.

If it looks like an RGB image, channels are written as a single RGB image. Otherwise, each channel is written separately.

If only a single stack will be converted, its name is suppressed in the output.

The following outputs are produced:

Output NameDefault?Description
"converted"yesAn image written in the default output format.
outputs from Task
Author:
Owen Feehan
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    afterAllJobsAreExecuted(NoSharedState sharedState, InputOutputContext context)
     
    NoSharedState
    beforeAnyJobIsExecuted(Outputter outputter, ConcurrencyPlan concurrencyPlan, List<NamedChannelsInput> inputs, ParametersExperiment parameters)
     
    protected OutputSequenceIndexed<Stack,String>
    createSharedStateJob(InputOutputContext context)
    Sets a new output-sequence for the series.
    OutputEnabledMutable
     
    void
    doStack(InputBound<NamedChannelsInput, NoSharedState> input, OutputSequenceIndexed<Stack,String> sharedStateJob, int seriesIndex, int numberSeries, InputOutputContext context)
    Processes one stack from a series.
    void
    endSeries(NoSharedState sharedStateTask, OutputSequenceIndexed<Stack,String> sharedStateJob, InputOutputContext context)
    Ends processing of a series.
    To convert as RGB or independently or in another way.
    ConvertChannelTo<?>
    Optionally, how to convert from one bit-depth to another (scaling, clamping etc.)
    boolean
     
    boolean
    If true, the series index is not included in the outputted file-names.
    void
    To convert as RGB or independently or in another way.
    void
    setChannelConverter(ConvertChannelTo<?> channelConverter)
    Optionally, how to convert from one bit-depth to another (scaling, clamping etc.)
    void
    setSuppressSeries(boolean suppressSeries)
    If true, the series index is not included in the outputted file-names.
    void
    startSeries(NoSharedState sharedStateTask, OutputSequenceIndexed<Stack,String> sharedStateJob, InputOutputContext context)
    Starts processing of a series.

    Methods inherited from class org.anchoranalysis.plugin.image.task.bean.RasterTask

    doJobOnInput, inputTypesExpected

    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

    • ConvertImageFormat

      public ConvertImageFormat()
  • Method Details

    • defaultOutputs

      public OutputEnabledMutable defaultOutputs()
      Overrides:
      defaultOutputs in class Task<NamedChannelsInput, NoSharedState>
    • hasVeryQuickPerInputExecution

      public boolean hasVeryQuickPerInputExecution()
      Specified by:
      hasVeryQuickPerInputExecution in class Task<NamedChannelsInput, NoSharedState>
    • beforeAnyJobIsExecuted

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

      protected OutputSequenceIndexed<Stack,String> createSharedStateJob(InputOutputContext context) throws JobExecutionException
      Sets a new output-sequence for the series.

      It's important to do this here rather than in beforeAnyJobIsExecuted(Outputter, ConcurrencyPlan, List, ParametersExperiment) as context is now bound with the directory/prefix related to the input.

      Specified by:
      createSharedStateJob in class RasterTask<NoSharedState, OutputSequenceIndexed<Stack,String>>
      Parameters:
      context - the input-output context associated with a particular job
      Returns:
      a newly created shared-state
      Throws:
      JobExecutionException - if an error occurs during job execution
    • startSeries

      public void startSeries(NoSharedState sharedStateTask, OutputSequenceIndexed<Stack,String> sharedStateJob, InputOutputContext context) throws JobExecutionException
      Description copied from class: RasterTask
      Starts processing of a series.

      This corresponds to the start of an input job, before any stacks in the series are processed.

      This should be called always once before all calls to RasterTask.doStack(org.anchoranalysis.experiment.task.InputBound<org.anchoranalysis.image.io.channel.input.NamedChannelsInput, S>, U, int, int, org.anchoranalysis.io.output.outputter.InputOutputContext).

      Specified by:
      startSeries in class RasterTask<NoSharedState, OutputSequenceIndexed<Stack,String>>
      Parameters:
      sharedStateTask - shared-state across all jobs in task
      sharedStateJob - shared-state across all stacks in a job (i.e. in all series)
      context - input-output context
      Throws:
      JobExecutionException - if an error occurs during job execution
    • doStack

      public void doStack(InputBound<NamedChannelsInput, NoSharedState> input, OutputSequenceIndexed<Stack,String> sharedStateJob, int seriesIndex, int numberSeries, InputOutputContext context) throws JobExecutionException
      Description copied from class: RasterTask
      Processes one stack from a series.

      This can be called many times in a job, once for each stack in the series.

      It is assumed each job may have only one series.

      Specified by:
      doStack in class RasterTask<NoSharedState, OutputSequenceIndexed<Stack,String>>
      Parameters:
      input - the input-object corresponding to this stack (a set of named-channels)
      sharedStateJob - shared-state across all stacks in a job (i.e. in all series)
      seriesIndex - the index of the input that is being currently processed from the series
      numberSeries - the total number of images in the series (constant for a given task)
      context - IO context
      Throws:
      JobExecutionException - if an error occurs during job execution
    • endSeries

      public void endSeries(NoSharedState sharedStateTask, OutputSequenceIndexed<Stack,String> sharedStateJob, InputOutputContext context) throws JobExecutionException
      Description copied from class: RasterTask
      Ends processing of a series.

      This corresponds to the end of an input job, after any stacks in the series are processed.

      This should be called always once after all calls to RasterTask.doStack(org.anchoranalysis.experiment.task.InputBound<org.anchoranalysis.image.io.channel.input.NamedChannelsInput, S>, U, int, int, org.anchoranalysis.io.output.outputter.InputOutputContext).

      Specified by:
      endSeries in class RasterTask<NoSharedState, OutputSequenceIndexed<Stack,String>>
      Parameters:
      sharedStateTask - shared-state across all jobs in task
      sharedStateJob - shared-state across all stacks in a job (i.e. in all series)
      context - input-output context
      Throws:
      JobExecutionException - if an error occurs during job execution
    • afterAllJobsAreExecuted

      public void afterAllJobsAreExecuted(NoSharedState sharedState, InputOutputContext context) throws ExperimentExecutionException
      Specified by:
      afterAllJobsAreExecuted in class Task<NamedChannelsInput, NoSharedState>
      Throws:
      ExperimentExecutionException
    • getChannelConversionStyle

      public ChannelConvertStyle getChannelConversionStyle()
      To convert as RGB or independently or in another way.
    • setChannelConversionStyle

      public void setChannelConversionStyle(ChannelConvertStyle channelConversionStyle)
      To convert as RGB or independently or in another way.
    • isSuppressSeries

      public boolean isSuppressSeries()
      If true, the series index is not included in the outputted file-names.

      It is always suppressed if only a single series exists.

    • setSuppressSeries

      public void setSuppressSeries(boolean suppressSeries)
      If true, the series index is not included in the outputted file-names.

      It is always suppressed if only a single series exists.

    • getChannelConverter

      public ConvertChannelTo<?> getChannelConverter()
      Optionally, how to convert from one bit-depth to another (scaling, clamping etc.)
    • setChannelConverter

      public void setChannelConverter(ConvertChannelTo<?> channelConverter)
      Optionally, how to convert from one bit-depth to another (scaling, clamping etc.)