Class Dct2dDirect

java.lang.Object
imagingbook.spectral.dct.Dct2dDirect
All Implemented Interfaces:
Dct2d
Direct Known Subclasses:
Dct2dDirect.Double, Dct2dDirect.Float

public class Dct2dDirect extends Object

Direct (slow) implementation of the 2-dimensional DCT using tabulated cosine values. Note that this class has no public constructor - instantiate sub-class Dct2dDirect.Float or Dct2dDirect.Double instead, as shown below. See Ch. 20 of [1] for additional details.

Usage example (for float data):

 float[][] data = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {-2, -1, 0}};
 int w = data.length;       // w = 4
 int h = data[0].length;    // h = 3
 Dct2d.Float dct = new Dct2dDirect.Float(w, h);
 dct.forward(data);  // data now is the 2D DCT spectrum
 dct.inverse(data);  // data now is the original 2D signal 
 ...

[1] W. Burger, M.J. Burge, Digital Image Processing – An Algorithmic Introduction, 3rd ed, Springer (2022).

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Two-dimensional DCT implementation using double data.
    static class 
    Two-dimensional DCT implementation using float data.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the 'height' of the 2D data array (length of dimension 1).
    int
    Returns the 'width' of the 2D data array (length of dimension 0).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getWidth

      public int getWidth()
      Description copied from interface: Dct2d
      Returns the 'width' of the 2D data array (length of dimension 0). Data arrays are indexed as data[x][y], with 0 ≤ x < width and 0 ≤ y < height.
      Specified by:
      getWidth in interface Dct2d
      Returns:
      the width of the 2D data array
    • getHeight

      public int getHeight()
      Description copied from interface: Dct2d
      Returns the 'height' of the 2D data array (length of dimension 1). Data arrays are indexed as data[x][y], with 0 ≤ x < width and 0 ≤ y < height.
      Specified by:
      getHeight in interface Dct2d
      Returns:
      the height of the 2D data array