Class PixelPack.PixelSlice

java.lang.Object
imagingbook.common.image.PixelPack.PixelSlice
Enclosing class:
PixelPack

public class PixelPack.PixelSlice extends Object
Inner class representing a single (scalar-valued) component of a (vector-valued) PixelPack.
  • Method Details

    • getVal

      public float getVal(int u, int v)
      Returns the pixel value for the specified image position.
      Parameters:
      u - the x-position
      v - the y-position
      Returns:
      the slice value
    • setVal

      public void setVal(int u, int v, float val)
      Sets the pixel value at the specified image position.
      Parameters:
      u - the x-position
      v - the y-position
      val - the new value
    • getIndex

      public int getIndex()
      Returns the slice index for this pixel slice, i.e, the component number in the containing pixel pack. -1 is returned if the pixel slice is not associated with a pixel pack.
      Returns:
      the slice index
    • getArray

      public float[] getArray()
      Returns a reference to the data array associated with this pixel slice.
      Returns:
      the data array
    • getFloatProcessor

      Returns a FloatProcessor for this PixelPack.PixelSlice sharing the internal pixel data (nothing is copied).
      Returns:
      a FloatProcessor
    • getFloatProcessorCopy

      Returns a FloatProcessor for this PixelPack.PixelSlice by copying the internal pixel data.
      Returns:
      a FloatProcessor
    • getLength

      public int getLength()
      Returns the length (number of pixels) of the associated 1D pixel array.
      Returns:
      the length of the image array
    • getWidth

      public int getWidth()
      Returns the width of the associated image (see also GridIndexer2D).
      Returns:
      the image width
    • getHeight

      public int getHeight()
      Returns the height of the associated image (see also GridIndexer2D).
      Returns:
      the image height
    • zero

      public void zero()
      Sets all pixel values to zero.
    • copyTo

      public void copyTo(PixelPack.PixelSlice other)
      Copies the contents of this pixel slice to another pixel slice.
      Parameters:
      other - the pixel slice to modified
    • get3x3Neighborhood

      public float[][] get3x3Neighborhood(int uc, int vc, float[][] nh)
      Returns the pixel values from the 3x3 neighborhood centered at the specified position. The 3x3 array nh[x][y] has the coordinates x = 0,..,2 and y = 0,..,2; the value at position [1][1] belongs to the specified position. If a non-null array is supplied, it is filled and returned. If null, a new array is created and returned.
      Parameters:
      uc - the center x-position
      vc - the center y-position
      nh - a 3x3 array or null
      Returns:
      a 3x3 array of pixel values