Class ImageData

    • Constructor Detail

      • ImageData

        ImageData​(java.awt.image.BufferedImage image)
    • Method Detail

      • fromFrequencyDomain

        public static ImageData fromFrequencyDomain​(MatrixStore<ComplexNumber> transformed)
        Creates a new image, transforming the input (back) from the frequency domain to the spatial domain using the inverse discrete Fourier transform. The transformation also reverts the shift of the frequency representation – the input should be in a format as returned by toFrequencyDomain(). The new image will be of the same dimensions as the input matrix.
        See Also:
        toFrequencyDomain()
      • newColour

        public static ImageData newColour​(int nbRows,
                                          int nbCols)
      • newGreyScale

        public static ImageData newGreyScale​(int nbRows,
                                             int nbCols)
      • newTransformation

        public static Transformation2D<ComplexNumber> newTransformation​(ImageData.FrequencyDomainUpdater updater)
        Creates a new transformation that can be used to transform a matrix of complex numbers in the frequency domain. The transformation will invoke the updater for each element in the input matrix, passing the distance from the centre of the matrix as the first argument. The distance is scaled so that the radius of the largest circle that can fit in the image rectangle is 100.
      • ofPowerSpectrum

        public static ImageData ofPowerSpectrum​(Access2D<ComplexNumber> transformed)
        Converts a matrix of complex numbers to an image of its power spectrum (log10 of the squared norms). In addition there is scaling applied to adapt the values towards the range [0,255].

        This is meant to be used with the output from toFrequencyDomain() to get a visual representation of the frequency content of an image.

      • read

        public static ImageData read​(java.io.File file)
      • read

        public static ImageData read​(java.io.File directory,
                                     java.lang.String fileName)
      • wrap

        public static ImageData wrap​(java.awt.image.BufferedImage image)
      • getGaussianKernel

        private static java.awt.image.Kernel getGaussianKernel​(double sigma,
                                                               int radius)
      • toRanged

        static int toRanged​(int value)
      • applyGaussianBlur

        public ImageData applyGaussianBlur​(double sigma)
        Creates a new image (of the same type) blurring the input using a Gaussian blur kernel.
        Parameters:
        sigma - The standard deviation of the Gaussian blur kernel
      • byteValue

        public byte byteValue​(int row,
                              int col)
        Specified by:
        byteValue in interface Access2D<java.lang.Double>
      • convertTo

        public ImageData convertTo​(int imageType)
        Creates a new image, converting the input to the specified image type in the process. BufferedImage.TYPE_BYTE_GRAY, BufferedImage.TYPE_INT_ARGB or any other valid type...
      • convertToGreyScale

        public ImageData convertToGreyScale()
        See Also:
        convertTo(int), BufferedImage.TYPE_BYTE_GRAY
      • countColumns

        public long countColumns()
        Description copied from interface: Structure2D
        Only need to implement if the structure may contain more than Integer.MAX_VALUE elements.
        Specified by:
        countColumns in interface Structure2D
        Returns:
        The number of columns
      • countRows

        public long countRows()
        Description copied from interface: Structure2D
        Only need to implement if the structure may contain more than Integer.MAX_VALUE elements.
        Specified by:
        countRows in interface Structure2D
        Returns:
        The number of rows
      • doubleValue

        public double doubleValue​(int row,
                                  int col)
        Description copied from interface: Access2D
        Extracts one element of this matrix as a double.
        Specified by:
        doubleValue in interface Access2D<java.lang.Double>
        Specified by:
        doubleValue in interface MatrixStore<java.lang.Double>
        Parameters:
        row - A row index.
        col - A column index.
        Returns:
        One matrix element
      • fillMatching

        public void fillMatching​(Access2D<?> values)
      • floatValue

        public float floatValue​(int row,
                                int col)
        Specified by:
        floatValue in interface Access2D<java.lang.Double>
      • get

        public java.lang.Double get​(int row,
                                    int col)
        Specified by:
        get in interface MatrixStore<java.lang.Double>
      • getColDim

        public int getColDim()
        Specified by:
        getColDim in interface Structure2D
        Returns:
        The number of columns
      • getImage

        public java.awt.image.BufferedImage getImage()
        Returns:
        The underlying BufferedImage
      • getRowDim

        public int getRowDim()
        Specified by:
        getRowDim in interface Structure2D
        Returns:
        The number of rows
      • intValue

        public int intValue​(int row,
                            int col)
        Specified by:
        intValue in interface Access2D<java.lang.Double>
      • resample

        public ImageData resample​(int nbRows,
                                  int nbCols)
        Will create a new image - the largest possible, with the same aspect ratio, that fits within the specified number of rows/columns (pixel height and width). Works well for both down-sampling and moderate up-sampling.
      • set

        public void set​(int row,
                        int col,
                        double value)
        Specified by:
        set in interface Mutate2D
      • set

        public void set​(int row,
                        int col,
                        float value)
        Specified by:
        set in interface Mutate2D
      • set

        public void set​(int row,
                        int col,
                        int value)
        Specified by:
        set in interface Mutate2D
      • set

        public void set​(int row,
                        int col,
                        long value)
        Specified by:
        set in interface Mutate2D
      • set

        public void set​(long row,
                        long col,
                        java.lang.Comparable<?> value)
        Specified by:
        set in interface Mutate2D
      • sliceAlphaChannel

        public ImageData sliceAlphaChannel()
      • sliceBlueChannel

        public ImageData sliceBlueChannel()
      • sliceGreenChannel

        public ImageData sliceGreenChannel()
      • sliceRedChannel

        public ImageData sliceRedChannel()
      • toFrequencyDomain

        public PhysicalStore<ComplexNumber> toFrequencyDomain()
        Transforms the spatial representation of the image to its frequency representation using the discrete Fourier transform.

        In addition the frequency representation is shifted so that the zero frequency is in the centre of the image.

        When you're done processing the frequency representation, you can transform it back to a spatial representation using fromFrequencyDomain(MatrixStore).

      • writeTo

        public void writeTo​(java.io.File file)
        The file format is derived from the file name ending (png, jpg...)
      • writeTo

        public void writeTo​(java.io.File directory,
                            java.lang.String fileName)
      • doubleValue

        private double doubleValue​(double row,
                                   double col)
      • getARGB

        protected int getARGB​(int row,
                              int col)
      • setARGB

        protected void setARGB​(int row,
                               int col,
                               int argb)