title: OpenCv - Implementing split and merge for DCT
body: <p>I am trying to implement a DCT code in Android. I'm using the split and merge method to obtain the original colors of the image.</p>
  
  <p>Here is the snippet of the code</p>
  
  <pre><code>image = Highgui.imread(imageName);  
  
  secondImage = new Mat(image.rows(), image.cols(), CvType.CV_32FC3);
  image.convertTo(secondImage, CvType.CV_32FC3);
  
  int m = Core.getOptimalDFTSize(image.rows());
  int n = Core.getOptimalDFTSize(image.cols()); // on the border add zero values
  
  Mat padded = new Mat(new Size(n, m), CvType.CV_32FC3); // expand input image to optimal size
  
  Imgproc.copyMakeBorder(secondImage, padded, 0, m - secondImage.rows(), 0, n - secondImage.cols(), Imgproc.BORDER_CONSTANT);
  
  List&lt;Mat&gt; planes = new ArrayList&lt;Mat&gt;();
  
  Core.split(padded, planes);
  List&lt;Mat&gt; outplanes = new ArrayList&lt;Mat&gt;(planes.size());
  for (int k = 0; k &lt; planes.size(); k++) { 
      outplanes.add(new Mat(padded.size(), CvType.CV_32FC1)); 
  } 
  
  Mat trans = new Mat(padded.size(), padded.type());  
  
  for (int k = 0; k &lt; planes.size(); k++) { 
      Core.dct(planes.get(k), outplanes.get(k));  
  } 
  
  List&lt;Mat&gt; ioutplanes = new ArrayList&lt;Mat&gt;(outplanes.size());
  for (int k = 0; k &lt; planes.size(); k++) { 
      ioutplanes.add(new Mat(padded.size(), CvType.CV_32FC1)); 
  }   
  
  for (int k = 0; k &lt; planes.size(); k++) {
      Core.idct(outplanes.get(k), ioutplanes.get(k));  
  } 
  Core.merge(ioutplanes, trans); 
  </code></pre>
  
  <p>This time got this exception :</p>
  
  <blockquote>
    <p>The function/feature is not implemented (Odd-size DCT's are not implemented) in void cv::dct(cv::InputArray, cv::OutputArray, int), file /home/reports/ci/slave_desktop/50-SDK/opencv/modules/core/src/dxt.cpp, line 2330</p>
  </blockquote>
  
  <p>Is this code correct? Your help is very much appreciated.</p>
  
  <p><strong>Updated:</strong> I noticed that the copyMakeBorder() is the one that caused my image size to be odd, that is why I am having this exception.</p>