1

I am trying to convert sobel of matlab to opencv manually.What is the equivalent if imfilter of matlab in opencv. I used filter2D but it does not give the same output.

MATLAB:

 bx = imfilter(gray_image,mask,'replicate');

opencv:

 Point anchor(0,0);
  float delta = 0.0;
  cv::filter2D(gray_img, bx, CV_32FC1, mask, anchor, delta, BORDER_REPLICATE);

How can I have the samle output as in MATLAB in opencv for this function???

user1583647
  • 1,227
  • 2
  • 24
  • 48
  • By 'manually' you mean you don't want to use the `sobel()` function in opencv? – Mahm00d Sep 05 '13 at 06:38
  • Yes because the output were different of matlab and opencv – user1583647 Sep 05 '13 at 07:31
  • Have you checked the OpenCV filters [documentation](http://docs.opencv.org/modules/imgproc/doc/filtering.html)? Maybe the generic `FilterEngine` class helps your case... – Mahm00d Sep 05 '13 at 08:56
  • How can I use the FilterEngine class do perform the same I tried but the output is still different. Can you provide me with a simple example? – user1583647 Sep 09 '13 at 11:06
  • 1
    Maybe the problem happens because of the difference in the ordering of the matrices in Matlab (column-major) vs. OCV (row-major order)? As addressed in this question: http://stackoverflow.com/questions/15231863/confusion-on-sobel-mask – Mahm00d Sep 17 '13 at 16:28

0 Answers0