How to get Inverse of DFT log spectrum in android?

asked 2014-10-11 22:30:24 -0600

Agtria gravatar image

updated 2014-10-12 02:51:32 -0600

berak gravatar image

Hi~

Can anyone tell me how to get Inverse of DFT log spectrum? I need to access that output pixel value to identification blur length. I've done forward DFT with this code but got confused how to get the inverse of log spectrum.

private Mat DFT (Mat singleChannel) {

int m = Core.getOptimalDFTSize(singleChannel.rows());

int n = Core.getOptimalDFTSize(singleChannel.cols());

Imgproc.cvtColor(singleChannel, singleChannel, Imgproc.COLOR_BGR2GRAY);

Mat padded = new Mat();

singleChannel.convertTo(singleChannel, CvType.CV_64FC2);

Imgproc.copyMakeBorder(singleChannel, padded, 0, m - singleChannel.rows(), 0, n - singleChannel.cols(), Imgproc.BORDER_CONSTANT);

List<mat> planes = new ArrayList<mat>();

planes.add(padded);

planes.add(Mat.zeros(padded.rows(), padded.cols(), CvType.CV_64FC1));

Mat complexI = Mat.zeros(padded.rows(), padded.cols(), CvType.CV_64FC2);

Mat complexI2 = Mat.zeros(padded.rows(), padded.cols(), CvType.CV_64FC2);

Core.merge(planes, complexI);

Core.dft(complexI, complexI2);

Core.split(complexI2, planes);

Mat mag = new Mat(planes.get(0).size(), planes.get(0).type());

Core.magnitude(planes.get(0), planes.get(1), mag);

Mat magI = mag;

Mat magI2 = new Mat(magI.size(), magI.type());

Mat magI3 = new Mat(magI.size(), magI.type());

Core.add(magI, Mat.ones(padded.rows(), padded.cols(), CvType.CV_64FC1), magI2);

Core.log(magI2, magI3);

return magI3;

}

edit retag flag offensive close merge delete