Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Complex number matrix in OpenCV (Java)

Hello

I am working on image data and the end goal is to use fourier transform on a product of the data and some complex matrix.

  • CV_64FC1 1000x1000 matrix of grayscaled image data (I have this)

  • Secondary 1000x1000 matrix of complex numbers (I don't have this)

The first matrix will multiply with the second complex matrix and after that I will use a fourier transform on it

Is there a way of doing this in OpenCV?

Complex number matrix in OpenCV (Java)

Hello

I am working on image data and the end goal is to use fourier transform on a product of the data and some complex matrix.

  • CV_64FC1 1000x1000 matrix of grayscaled image data (I have this)

  • Secondary 1000x1000 matrix of complex numbers (I don't have this)

The first matrix will multiply with the second complex matrix and after that I will use a fourier transform on it

Is there a way of doing this in OpenCV?

edit:

// image matrix
Bitmap bitmap_image = ...
Mat matrix = new Mat(1000, 1000, CvType.CV_64FC1);
Utils.bitmapToMat(bitmap_image, matrix); 
Imgproc.cvtColor(matrix, matrix, Imgproc.COLOR_RGBA2GRAY);
matrix.convertTo(matrix, CvType.CV_64FC1, 1.0/255.0); // type when initialised is ignored
// secondary matrix
Mat secondary_matrix = new Mat(1000, 1000, CvType.CV_64FC1);
for (int i=0; i<1000; i++) {
    for (int j=0; j<1000; j++) {
        // ... do some stuff to get value
        secondary matrix.put(i,j,value);
    }
}
// now need to make secondary matrix complex by multiplying by some function of i

Complex number matrix in OpenCV (Java)

Hello

I am working on image data and the end goal is to use fourier transform on a product of the data and some complex matrix.

  • CV_64FC1 1000x1000 matrix of grayscaled image data (I have this)

  • Secondary 1000x1000 matrix of complex numbers (I don't have this)

The first matrix will multiply with the second complex matrix and after that I will use a fourier transform on it

Is there a way of doing this in OpenCV?

edit:

// image matrix
Bitmap bitmap_image = ...
Mat matrix = new Mat(1000, 1000, CvType.CV_64FC1);
Utils.bitmapToMat(bitmap_image, matrix); 
Imgproc.cvtColor(matrix, matrix, Imgproc.COLOR_RGBA2GRAY);
matrix.convertTo(matrix, CvType.CV_64FC1, 1.0/255.0); // type when initialised is ignored
// secondary matrix
Mat secondary_matrix = new Mat(1000, 1000, CvType.CV_64FC1);
for (int i=0; i<1000; i++) {
    for (int j=0; j<1000; j++) {
        // ... do some stuff to get value
        secondary matrix.put(i,j,value);
    }
}
// now need to make secondary matrix complex by multiplying by some function of i
// complex numbers created in Java according to the Apache Commons complex class

Complex number matrix in OpenCV (Java)

Hello

I am working on image data and the end goal is to use fourier transform on a product of the data and some complex matrix.

  • CV_64FC1 1000x1000 matrix of grayscaled image data (I have this)

  • Secondary 1000x1000 matrix of complex numbers (I don't have this)

The first matrix will multiply with the second complex matrix and after that I will use a fourier transform on it

Is there a way of doing this in OpenCV?

edit:

// image matrix
Bitmap bitmap_image = ...
Mat matrix = new Mat(1000, 1000, CvType.CV_64FC1);
Utils.bitmapToMat(bitmap_image, matrix); 
Imgproc.cvtColor(matrix, matrix, Imgproc.COLOR_RGBA2GRAY);
matrix.convertTo(matrix, CvType.CV_64FC1, 1.0/255.0); // type when initialised is ignored
// secondary matrix
Mat secondary_matrix = new Mat(1000, 1000, CvType.CV_64FC1);
for (int i=0; i<1000; i++) {
    for (int j=0; j<1000; j++) {
        // ... do some stuff to get value
        secondary matrix.put(i,j,value);
    }
}
// now need to make secondary matrix complex by multiplying by some function of i
// complex numbers created in Java according to the Apache Commons complex class

Complex number matrix in OpenCV (Java)

Hello

I am working on image data and the end goal is to use fourier transform on a product of the data and some complex matrix.

  • CV_64FC1 1000x1000 matrix of grayscaled image data (I have this)

  • Secondary 1000x1000 matrix of complex numbers (I don't have this)

The first matrix will multiply with the second complex matrix and after that I will use a fourier transform on it

Is there a way of doing this in OpenCV?

edit:

// image matrix
Bitmap bitmap_image = ...
Mat matrix = new Mat(1000, 1000, CvType.CV_64FC1);
Utils.bitmapToMat(bitmap_image, matrix); 
Imgproc.cvtColor(matrix, matrix, Imgproc.COLOR_RGBA2GRAY);
matrix.convertTo(matrix, CvType.CV_64FC1, 1.0/255.0); // type when initialised is ignored
// secondary matrix
Mat secondary_matrix = new Mat(1000, 1000, CvType.CV_64FC1);
for (int i=0; i<1000; i++) {
    for (int j=0; j<1000; j++) {
        // ... do some stuff to get value
        secondary matrix.put(i,j,value);
    }
}
// now need to make secondary matrix complex by multiplying by some function of i

edit2:

Context: I have a hologram image in OpenCV matrix form (single channel), I have another matrix filled with real numbers (single channel) - this matrix represents the sampling period in the spatial domain. This latter matrix isn't used directly, it passes through an e^(i*...) function to make the values complex. Finally, a discrete fourier transform is applied on the per-element product of the image data and this complex matrix I just described.