Package ome.util

Class PixelData


  • public class PixelData
    extends java.lang.Object
    Represents a block of pixel data.
    Since:
    3.0
    See Also:
    "ome.io.nio.PixelBuffer"
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int BIT
      Identifies the type used to store pixel values.
      static int BYTE
      Identifies the type used to store pixel values.
      protected int bytesPerPixel
      The number of bytes per pixel.
      static java.lang.String CONFIG_KEY  
      protected java.nio.ByteBuffer data
      The pixels data backing buffer.
      static int DOUBLE
      Identifies the type used to store pixel values.
      static int FLOAT
      Identifies the type used to store pixel values.
      static int INT
      Identifies the type used to store pixel values.
      protected boolean isFloat
      If the data is floating point.
      protected boolean isSigned
      If the data is signed.
      protected int javaType
      The pixels type as it would be represented in Java.
      static int LONG
      Identifies the type used to store pixel values.
      protected double maximum
      The maximum pixel value for the pixels type of the pixel data.
      protected double minimum
      The minimum pixel value for the pixels type of the pixel data.
      protected java.lang.String pixelsType
      Type of the pixel data.
      static int SHORT
      Identifies the type used to store pixel values.
    • Constructor Summary

      Constructors 
      Constructor Description
      PixelData​(java.lang.String pixelsType, java.nio.ByteBuffer data)
      Default constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int bytesPerPixel()
      Returns the number of byte per pixel for the pixel data.
      void dispose()
      Attempt to free up any native memory resources associated with the data buffer.
      static int getBitDepth​(java.lang.String type)
      Retrieves the bit width of a particular PixelsType.
      java.nio.ByteBuffer getData()
      Returns the backing buffer for the pixel data.
      double getMaximum()
      Returns the minimum pixel value this pixel data supports.
      double getMinimum()
      Returns the minimum pixel value this pixel data supports.
      java.nio.ByteOrder getOrder()
      Returns the byte order of the backing buffer.
      double getPixelValue​(int offset)
      Returns the pixel intensity value of the pixel at a given offset within the backing buffer.
      double getPixelValueDirect​(int offset)
      Returns the pixel intensity value of the pixel at a given offset within the backing buffer.
      boolean in​(java.lang.String[] strings)
      Returns whether or not the pixel data type is is one of the elements in an array.
      boolean isFloat()
      Returns whether or not the data is floating point.
      boolean isSigned()
      Returns whether or not the data is signed.
      int javaType()
      Returns the Java type that has the same byte width of the pixel data.
      void setOrder​(java.nio.ByteOrder order)
      Set the byte order of the backing buffer.
      void setPixelValue​(int offset, double value)
      Sets the pixel intensity value of the pixel at a given offset within the backing buffer.
      void setPixelValueDirect​(int offset, double value)
      Sets the pixel intensity value of the pixel at a given offset within the backing buffer.
      int size()
      Returns the pixel count of this block of pixel data.
      • Methods inherited from class java.lang.Object

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

      • BYTE

        public static final int BYTE
        Identifies the type used to store pixel values.
        See Also:
        Constant Field Values
      • SHORT

        public static final int SHORT
        Identifies the type used to store pixel values.
        See Also:
        Constant Field Values
      • INT

        public static final int INT
        Identifies the type used to store pixel values.
        See Also:
        Constant Field Values
      • LONG

        public static final int LONG
        Identifies the type used to store pixel values.
        See Also:
        Constant Field Values
      • FLOAT

        public static final int FLOAT
        Identifies the type used to store pixel values.
        See Also:
        Constant Field Values
      • DOUBLE

        public static final int DOUBLE
        Identifies the type used to store pixel values.
        See Also:
        Constant Field Values
      • BIT

        public static final int BIT
        Identifies the type used to store pixel values.
        See Also:
        Constant Field Values
      • pixelsType

        protected java.lang.String pixelsType
        Type of the pixel data.
      • data

        protected java.nio.ByteBuffer data
        The pixels data backing buffer.
      • isSigned

        protected boolean isSigned
        If the data is signed.
      • isFloat

        protected boolean isFloat
        If the data is floating point.
      • javaType

        protected int javaType
        The pixels type as it would be represented in Java.
      • bytesPerPixel

        protected int bytesPerPixel
        The number of bytes per pixel.
      • minimum

        protected double minimum
        The minimum pixel value for the pixels type of the pixel data.
      • maximum

        protected double maximum
        The maximum pixel value for the pixels type of the pixel data.
    • Constructor Detail

      • PixelData

        public PixelData​(java.lang.String pixelsType,
                         java.nio.ByteBuffer data)
        Default constructor.
        Parameters:
        pixelsType - The OME pixels type.
        data - The raw pixel data.
    • Method Detail

      • in

        public boolean in​(java.lang.String[] strings)
        Returns whether or not the pixel data type is is one of the elements in an array.
        Parameters:
        strings - The strings for which you want to check against.
        Returns:
        See above.
      • bytesPerPixel

        public int bytesPerPixel()
        Returns the number of byte per pixel for the pixel data.
        Returns:
        See above.
      • isSigned

        public boolean isSigned()
        Returns whether or not the data is signed.
        Returns:
        See above.
      • isFloat

        public boolean isFloat()
        Returns whether or not the data is floating point.
        Returns:
        See above.
      • javaType

        public int javaType()
        Returns the Java type that has the same byte width of the pixel data.
        Returns:
        See above.
      • getMinimum

        public double getMinimum()
        Returns the minimum pixel value this pixel data supports.
        Returns:
        See above.
      • getMaximum

        public double getMaximum()
        Returns the minimum pixel value this pixel data supports.
        Returns:
        See above.
      • setPixelValue

        public void setPixelValue​(int offset,
                                  double value)
        Sets the pixel intensity value of the pixel at a given offset within the backing buffer. This method takes into account bytes per pixel.
        Parameters:
        offset - The relative offset (taking into account the number of bytes per pixel) within the backing buffer.
        value - Pixel value to set.
      • setPixelValueDirect

        public void setPixelValueDirect​(int offset,
                                        double value)
        Sets the pixel intensity value of the pixel at a given offset within the backing buffer. This method does not take into account bytes per pixel.
        Parameters:
        offset - The absolute offset within the backing buffer.
        value - Pixel value to set.
      • getPixelValue

        public double getPixelValue​(int offset)
        Returns the pixel intensity value of the pixel at a given offset within the backing buffer. This method takes into account bytes per pixel.
        Parameters:
        offset - The relative offset (taking into account the number of bytes per pixel) within the backing buffer.
        Returns:
        The intensity value.
      • getPixelValueDirect

        public double getPixelValueDirect​(int offset)
        Returns the pixel intensity value of the pixel at a given offset within the backing buffer. This method does not take into account bytes per pixel.
        Parameters:
        offset - The absolute offset within the backing buffer.
        Returns:
        The intensity value.
      • getData

        public java.nio.ByteBuffer getData()
        Returns the backing buffer for the pixel data.
        Returns:
        See above.
      • getOrder

        public java.nio.ByteOrder getOrder()
        Returns the byte order of the backing buffer.
        Returns:
        See above.
      • setOrder

        public void setOrder​(java.nio.ByteOrder order)
        Set the byte order of the backing buffer.
        Parameters:
        order - The byte order.
      • size

        public int size()
        Returns the pixel count of this block of pixel data.
        Returns:
        See above.
      • getBitDepth

        public static int getBitDepth​(java.lang.String type)
        Retrieves the bit width of a particular PixelsType.
        Parameters:
        type - a pixel type.
        Returns:
        width of a single pixel value in bits.
      • dispose

        public void dispose()
        Attempt to free up any native memory resources associated with the data buffer. This is a temporary workaround hoped to ameliorate trac ticket #11250. This PixelData instance must not be accessed by any thread after this method is called. If not called, the resources should eventually be freed anyway by garbage collection and finalization.