Class Renderer


  • public class Renderer
    extends java.lang.Object
    Transforms raw image data into an RGB image that can be displayed on screen.

    Every instance of this class works against a given pixels set within an OME Image (recall that an Image can have more than one pixels set) and holds the rendering environment for that pixels set. Said environment is composed of:

    • Resources to access pixels raw data and metadata.
    • Cached pixels metadata (statistic measurements).
    • Settings that define the transformation context — that is, a specification of how raw data is to be transformed into an image that can be displayed on screen.
    • Resources to apply the transformations defined by the transformation context to raw pixels.

    This class delegates the actual rendering to a RenderingStrategy, which is selected depending on how transformed data is to be mapped into a color space.

    Since:
    OME2.2
    See Also:
    RenderingDef, QuantumManager, CodomainChain, RenderingStrategy
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int MAX_CHANNELS
      The maximum number of channels.
      static java.lang.String MODEL_GREYSCALE
      Identifies the type used to store model values.
      static java.lang.String MODEL_HSB
      Identifies the type used to store model values.
      static java.lang.String MODEL_RGB
      Identifies the type used to store model values.
      static java.lang.String PHOTOMETRIC_MONOCHROME
      Deprecated.
    • Constructor Summary

      Constructors 
      Constructor Description
      Renderer​(QuantumFactory quantumFactory, java.util.List<ome.model.enums.RenderingModel> renderingModels, ome.model.core.Pixels pixelsObj, ome.model.display.RenderingDef renderingDefObj, ome.io.nio.PixelBuffer bufferObj, omeis.providers.re.lut.LutProvider lutProvider)
      Creates a new instance to render the specified pixels set and get this new instance ready for rendering.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes the buffer, cleaning up file state.
      ome.model.display.ChannelBinding[] getChannelBindings()
      Returns an array containing the channel bindings.
      java.util.List<ome.model.display.ChannelBinding> getChannelBindingsAsList()
      Returns a list containing the channel bindings.
      CodomainChain getCodomainChain​(int channel)
      Returns the object that defines the sequence of spatial transformations to be applied to quantized data.
      java.util.List getCodomainMapContexts()
      Returns the list of codomain map contexts.
      static int[] getColorArray​(ome.model.display.ChannelBinding channel)
      Returns an array whose ascending indices represent the color components Red, Green and Blue.
      int getImageSize​(omeis.providers.re.data.PlaneDef pd)
      Returns the size, in bytes, of the RGBBuffer that would be rendered from the plane selected by pd.
      ome.model.core.Pixels getMetadata()
      Returns the Pixels set the rendering engine is for.
      Optimizations getOptimizations()
      Returns the optimizations that the renderer currently has enabled.
      java.util.Map<byte[],​java.lang.Integer> getOverlays()
      Returns the current set of overlays to be rendered.
      ome.io.nio.PixelBuffer getPixels()
      Returns the object that allows to access the pixels raw data.
      ome.model.enums.PixelsType getPixelsType()
      Returns the pixels type.
      double getPixelsTypeLowerBound​(int w)
      Returns the minimum value for that channels depending on the pixels type and the original range (globalmax, globalmin)
      double getPixelsTypeUpperBound​(int w)
      Returns the maximum value for that channels depending on the pixels type and the original range (globalmax, globalmin)
      java.lang.String getPlaneDimsAsString​(omeis.providers.re.data.PlaneDef pd)
      Returns a string with the dimensions of the specified plane.
      omeis.providers.re.QuantumManager getQuantumManager()
      Returns the object that manages and allows to retrieve the objects that are used to quantize wavelength data.
      ome.model.display.RenderingDef getRenderingDef()
      Returns the settings that define the transformation context.
      java.util.List<java.util.List<java.lang.Integer>> getResolutionDescriptions()
      Returns the image's size information per resolution level.
      int getResolutionLevel()
      Retrieves the active resolution level.
      int getResolutionLevels()
      Retrieves the number of resolution levels that the backing pixels pyramid contains.
      RenderingStats getStats()
      Returns a RenderingStats object that the rendering strategy can use to track performance.
      java.awt.Dimension getTileSize()
      Retrieves the tile size for the pixel store.
      boolean isPixelsTypeSigned()
      Returns true if the pixels type is signed, false otherwise.
      omeis.providers.re.RGBBuffer render​(omeis.providers.re.data.PlaneDef pd)
      Renders the data selected by pd according to the current rendering settings.
      int[] renderAsPackedInt​(omeis.providers.re.data.PlaneDef pd, ome.io.nio.PixelBuffer newBuffer)
      Renders the data selected by pd according to the current rendering settings.
      void setActive​(int w, boolean active)
      Makes a particular channel active or inactive.
      void setChannelLookupTable​(int w, java.lang.String lookupTable)
      Sets the lookup table associated to the channel.
      void setChannelWindow​(int w, double start, double end)
      Sets the pixels intensity interval for the specified channel.
      void setCodomainInterval​(int start, int end)
      Sets the codomain interval i.e.
      void setDefaultT​(int t)
      Sets the default timepoint index.
      void setDefaultZ​(int z)
      Sets the index of the default focal section.
      void setModel​(ome.model.enums.RenderingModel model)
      Specifies the model that dictates how transformed raw data has to be mapped onto a color space.
      void setOverlays​(java.util.Map<byte[],​java.lang.Integer> overlays)
      Sets a map of overlays to be rendered.
      void setQuantizationMap​(int w, ome.model.enums.Family family, double coefficient, boolean noiseReduction)
      Sets the mapping strategy for the specified channel.
      void setQuantumStrategy​(int bitResolution)
      Sets the bit resolution.
      void setResolutionLevel​(int resolutionLevel)
      Sets the active resolution level.
      void setRGBA​(int w, int red, int green, int blue, int alpha)
      Sets the color associated to the specified channel.
      void updateQuantumManager()
      Updates the QuantumManager and configures it according to the current quantum definition.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MAX_CHANNELS

        public static final int MAX_CHANNELS
        The maximum number of channels.
        See Also:
        Constant Field Values
      • MODEL_GREYSCALE

        public static final java.lang.String MODEL_GREYSCALE
        Identifies the type used to store model values.
        See Also:
        Constant Field Values
      • MODEL_RGB

        public static final java.lang.String MODEL_RGB
        Identifies the type used to store model values.
        See Also:
        Constant Field Values
      • MODEL_HSB

        public static final java.lang.String MODEL_HSB
        Identifies the type used to store model values.
        See Also:
        Constant Field Values
      • PHOTOMETRIC_MONOCHROME

        @Deprecated
        public static final java.lang.String PHOTOMETRIC_MONOCHROME
        Deprecated.
        Identifies the type used to store photometric interpretation values.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Renderer

        public Renderer​(QuantumFactory quantumFactory,
                        java.util.List<ome.model.enums.RenderingModel> renderingModels,
                        ome.model.core.Pixels pixelsObj,
                        ome.model.display.RenderingDef renderingDefObj,
                        ome.io.nio.PixelBuffer bufferObj,
                        omeis.providers.re.lut.LutProvider lutProvider)
        Creates a new instance to render the specified pixels set and get this new instance ready for rendering.
        Parameters:
        quantumFactory - a populated quantum factory.
        renderingModels - an enumerated list of all rendering models.
        pixelsObj - Pixels object.
        renderingDefObj - Rendering definition object.
        bufferObj - PixelBuffer object.
        lutProvider - provider of the available lookup tables.
        Throws:
        java.lang.NullPointerException - If null parameters are passed.
    • Method Detail

      • setModel

        public void setModel​(ome.model.enums.RenderingModel model)
        Specifies the model that dictates how transformed raw data has to be mapped onto a color space. This class delegates the actual rendering to a RenderingStrategy, which is selected depending on that model. So setting the model also results in changing the rendering strategy.
        Parameters:
        model - Identifies the color space model.
      • setDefaultZ

        public void setDefaultZ​(int z)
        Sets the index of the default focal section. This index is used to define a default plane.
        Parameters:
        z - The stack index.
        See Also:
        setDefaultT(int)
      • setDefaultT

        public void setDefaultT​(int t)
        Sets the default timepoint index. This index is used to define a default plane.
        Parameters:
        t - The timepoint index.
        See Also:
        setDefaultZ(int)
      • setOverlays

        public void setOverlays​(java.util.Map<byte[],​java.lang.Integer> overlays)
        Sets a map of overlays to be rendered.
        Parameters:
        overlays - Overlay to color map.
      • getOverlays

        public java.util.Map<byte[],​java.lang.Integer> getOverlays()
        Returns the current set of overlays to be rendered.
        Returns:
        Overlay to color map.
      • updateQuantumManager

        public void updateQuantumManager()
        Updates the QuantumManager and configures it according to the current quantum definition.
      • render

        public omeis.providers.re.RGBBuffer render​(omeis.providers.re.data.PlaneDef pd)
                                            throws java.io.IOException,
                                                   QuantizationException
        Renders the data selected by pd according to the current rendering settings. The passed argument selects a plane orthogonal to one of the X, Y, or Z axes. How many wavelengths are rendered and what color model is used depends on the current rendering settings.
        Parameters:
        pd - Selects a plane orthogonal to one of the X, Y, or Z axes.
        Returns:
        An RGB image ready to be displayed on screen.
        Throws:
        java.io.IOException - If an error occurred while trying to pull out data from the pixels data repository.
        QuantizationException - If an error occurred while quantizing the pixels raw data.
        java.lang.NullPointerException - If pd is null.
      • renderAsPackedInt

        public int[] renderAsPackedInt​(omeis.providers.re.data.PlaneDef pd,
                                       ome.io.nio.PixelBuffer newBuffer)
                                throws java.io.IOException,
                                       QuantizationException
        Renders the data selected by pd according to the current rendering settings. The passed argument selects a plane orthogonal to one of the X, Y, or Z axes. How many wavelengths are rendered and what color model is used depends on the current rendering settings.
        Parameters:
        pd - Selects a plane orthogonal to one of the X, Y, or Z axes.
        newBuffer - The pixel buffer to use in place of the one currently defined in the renderer. This will not change the state of the Renderer. If null is passed the existing pixel buffer will be used.
        Returns:
        An RGB image ready to be displayed on screen.
        Throws:
        java.io.IOException - If an error occurred while trying to pull out data from the pixels data repository.
        QuantizationException - If an error occurred while quantizing the pixels raw data.
        java.lang.NullPointerException - If pd is null.
      • getImageSize

        public int getImageSize​(omeis.providers.re.data.PlaneDef pd)
        Returns the size, in bytes, of the RGBBuffer that would be rendered from the plane selected by pd. Note that the returned value also depends on the current rendering strategy which is selected by the setModel method. So a subsequent invocation of this method may return a different value if the setModel method has been called since the first call to this method.
        Parameters:
        pd - Selects a plane orthogonal to one of the X, Y, or Z axes.
        Returns:
        See above.
        Throws:
        java.lang.NullPointerException - If pd is null.
      • getPlaneDimsAsString

        public java.lang.String getPlaneDimsAsString​(omeis.providers.re.data.PlaneDef pd)
        Returns a string with the dimensions of the specified plane. The returned string has the format AxB, where A is the number of pixels on the X1-axis and B the the number of pixels on the the X2-axis. The X1-axis is the X-axis in the case of an XY or XZ plane. Otherwise it is the Z-axis — ZY plane. The X2-axis is the Y-axis in the case of an XY or ZY plane. Otherwise it is the Z-axis — XZ plane.
        Parameters:
        pd - Selects a plane orthogonal to one of the X, Y, or Z axes.
        Returns:
        See above.
        Throws:
        java.lang.NullPointerException - If pd is null.
      • getChannelBindings

        public ome.model.display.ChannelBinding[] getChannelBindings()
        Returns an array containing the channel bindings. The dimension of the array equals the number of channels.
        Returns:
        See above.
      • getCodomainMapContexts

        public java.util.List getCodomainMapContexts()
        Returns the list of codomain map contexts. One per channel.
        Returns:
        See above.
      • getChannelBindingsAsList

        public java.util.List<ome.model.display.ChannelBinding> getChannelBindingsAsList()
        Returns a list containing the channel bindings. The dimension of the array equals the number of channels.
        Returns:
        See above.
      • getRenderingDef

        public ome.model.display.RenderingDef getRenderingDef()
        Returns the settings that define the transformation context. That is, a specification of how raw data is to be transformed into an image that can be displayed on screen.
        Returns:
        See above.
      • getQuantumManager

        public omeis.providers.re.QuantumManager getQuantumManager()
        Returns the object that manages and allows to retrieve the objects that are used to quantize wavelength data.
        Returns:
        See above.
      • getPixels

        public ome.io.nio.PixelBuffer getPixels()
        Returns the object that allows to access the pixels raw data.
        Returns:
        See above.
      • getMetadata

        public ome.model.core.Pixels getMetadata()
        Returns the Pixels set the rendering engine is for.
        Returns:
        See above.
      • getPixelsType

        public ome.model.enums.PixelsType getPixelsType()
        Returns the pixels type.
        Returns:
        A pixels type enumeration object.
      • getCodomainChain

        public CodomainChain getCodomainChain​(int channel)
        Returns the object that defines the sequence of spatial transformations to be applied to quantized data.
        Parameters:
        channel -
        Returns:
        See above.
      • getStats

        public RenderingStats getStats()
        Returns a RenderingStats object that the rendering strategy can use to track performance. A new stats object is created upon each invocation of the render method.
        Returns:
        The stats object.
      • setQuantumStrategy

        public void setQuantumStrategy​(int bitResolution)
        Sets the bit resolution.
        Parameters:
        bitResolution - The value to set.
      • setCodomainInterval

        public void setCodomainInterval​(int start,
                                        int end)
        Sets the codomain interval i.e. a sub-interval of [0, 255].
        Parameters:
        start - The lower bound of the interval.
        end - The upper bound of the interval.
      • setChannelWindow

        public void setChannelWindow​(int w,
                                     double start,
                                     double end)
        Sets the pixels intensity interval for the specified channel.
        Parameters:
        w - The channel index.
        start - The lower bound of the interval.
        end - The upper bound of the interval.
      • setQuantizationMap

        public void setQuantizationMap​(int w,
                                       ome.model.enums.Family family,
                                       double coefficient,
                                       boolean noiseReduction)
        Sets the mapping strategy for the specified channel.
        Parameters:
        w - The channel index.
        family - The mapping family.
        coefficient - The coefficient identifying a curve in the family.
        noiseReduction - Pass true to select the noiseReduction algorithm, false otherwise.
      • setRGBA

        public void setRGBA​(int w,
                            int red,
                            int green,
                            int blue,
                            int alpha)
        Sets the color associated to the specified channel.
        Parameters:
        w - The channel index.
        red - The red component of the color.
        green - The green component of the color.
        blue - The blue component of the color.
        alpha - The alpha component of the color.
      • setChannelLookupTable

        public void setChannelLookupTable​(int w,
                                          java.lang.String lookupTable)
        Sets the lookup table associated to the channel.
        Parameters:
        w - The selected channel.
        lookupTable - The lookup table.
      • setActive

        public void setActive​(int w,
                              boolean active)
        Makes a particular channel active or inactive.
        Parameters:
        w - the wavelength index to toggle.
        active - true to set the channel active or false to set the channel inactive.
      • getOptimizations

        public Optimizations getOptimizations()
        Returns the optimizations that the renderer currently has enabled.
        Returns:
        See above.
      • close

        public void close()
        Closes the buffer, cleaning up file state.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • getColorArray

        public static int[] getColorArray​(ome.model.display.ChannelBinding channel)
        Returns an array whose ascending indices represent the color components Red, Green and Blue.
        Parameters:
        channel - the color to decompose into an array.
        Returns:
        See above.
      • isPixelsTypeSigned

        public boolean isPixelsTypeSigned()
        Returns true if the pixels type is signed, false otherwise.
        Returns:
        See above.
      • getPixelsTypeLowerBound

        public double getPixelsTypeLowerBound​(int w)
        Returns the minimum value for that channels depending on the pixels type and the original range (globalmax, globalmin)
        Parameters:
        w - The channel index.
        Returns:
        See above.
      • getPixelsTypeUpperBound

        public double getPixelsTypeUpperBound​(int w)
        Returns the maximum value for that channels depending on the pixels type and the original range (globalmax, globalmin)
        Parameters:
        w - The channel index.
        Returns:
        See above.
      • setResolutionLevel

        public void setResolutionLevel​(int resolutionLevel)
        Sets the active resolution level.
        Parameters:
        resolutionLevel - The resolution level to be used by the renderer.
        See Also:
        PixelBuffer.setResolutionLevel(int)
      • getResolutionLevel

        public int getResolutionLevel()
        Retrieves the active resolution level.
        Returns:
        The active resolution level.
        See Also:
        PixelBuffer.getResolutionLevel()
      • getResolutionLevels

        public int getResolutionLevels()
        Retrieves the number of resolution levels that the backing pixels pyramid contains.
        Returns:
        The number of resolution levels. This value does not necessarily indicate either the presence or absence of a pixels pyramid.
        See Also:
        PixelBuffer.getResolutionLevels()
      • getResolutionDescriptions

        public java.util.List<java.util.List<java.lang.Integer>> getResolutionDescriptions()
        Returns the image's size information per resolution level.
        Returns:
        See above.
      • getTileSize

        public java.awt.Dimension getTileSize()
        Retrieves the tile size for the pixel store.
        Returns:
        The dimension of the tile or null if the pixel buffer is not tiled.