Skip to content Skip to sidebar Skip to footer

Convert Opencv Dct To Android

I'm trying to implement a DCT code in Android. I'm testing out using the code but just changing to DCT instead of DFT : Convert OpenCv DFT example from C++ to Android. There have b

Solution 1:

You have this line:

image.convertTo(secondImage, CvType.CV_64FC1);

but then you don't use secondImage again, just image. Try:

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

and see how you get on.

Also DCT looks like it only works on reals not complex numbers like DFT and so you don't need to add a second channel to zero the imaginary part. You can work directly with the padded variable, so:

Mat result = new Mat(padded.size(), padded.type());

then

Core.dct(padded, result);

also, the original image needs to be single channel - so a greyscale. When you call Highgui.imread the image that will be loaded is multichannel - on my device it is 3 channel in BGR format. You can convert it to greyscale using Imgproc.cvtColor but it would be simpler just to load it as grey scale in the first place:

image = Highgui.imread(imageName, Highgui.CV_LOAD_IMAGE_GRAYSCALE); 

Post a Comment for "Convert Opencv Dct To Android"