Matlab to Opencv Code
|September 29, 2014
Posted by forumadmin
I = imread('C:\\Users\\20055316\\Desktop\\blurMetric\\Illumination_Changes\\z_0001.bmp');
I = double(I);
[y, x] = size(I);
Hv = [1 1 1 1 1 1 1 1 1]/9;
Hh = Hv';
B_Ver = imfilter(I,Hv);%blur the input image in vertical direction
B_Hor = imfilter(I,Hh);%blur the input image in horizontal direction
I need to convert the above Matlab code to OpenCV,
i tried using Filter2D but did not get the desired result.
The openCV code is as shown below
Mat oMatTempImage = imread("C:\\Users\\20055316\\Desktop\\blurMetric\\Illumination_Changes\\z_0001.bmp");
cvtColor(oMatTempImage, oMatTempImage, CV_BGR2RGB);
Mat oMatVerticalKernel = Mat(1, 9, CV_32FC1);
for (int nColItr = 0; nColItr < 9; nColItr++)
oMatVerticalKernel.at<float>(0, nColItr) = 1.0f / 9.0f;
filter2D(oMatTempImage, oMatVeriticalBlurr, -1, oMatVerticalKernel);
filter2D(oMatTempImage, oMatHorizontalBlurr, -1, oMatHorizontalKernel);
i am not getting similar results, Kindly help me out please.
More Related Questions
- Detecting thin lines in blurry image I'm looking for some ideas to detect lines in the attached image. Lines are assumed to be vertical, but their are very poor quality and there are only 2-3 pixels between each blurry […]
- Why luma parameter differs in opencv and matlab? I'm using this code to extract luma from an image in matlab:
I = imread('myphoto.bmp');
I = rgb2ycbcr(I);
I = I[:, :, 1];
And this one to do the same in […]
- QNativeImage: Unable to attach to shared memory segment. I saw there is one same thread: OpenCv Error in C Wrapper for imread: QNativeImage: Unable to attach to shared memory segment That thread was posted about 4 months ago. No any answer. […]
- Extracting segments from a list of 8-connected pixels Current situation : I'm trying to extract segments from an image. Thanks to openCV's findContours() method, I now have a list of 8-connected point for every contours. However, these lists […]
- Improving background subtraction I am working on video processing project to detect fore ground objects. Below is a part of my code which is used to separate foreground and background.
- Multiplication of 2 images where the images have different models in OPEN CV I'm trying to multiply two images of different models, in my case HSV and YCRCB.
I get the "vector is out of bound error" every time.
I have checked the sizes of the input images being […]
- How can I found the circles on image avoiding the internal circles? How can I found the circles on image using the method minEnclosingCircle but avoid the internal circles?
I'm using the opencv with c++ to detect circles on a image. I was using the method […]
- How do I go about breaking apart this image into two separate lines with opencv? I have this image that I'd like to break into 2 separate diagonal lines by removing the vertical line using opencv. I thought about dilation, but this makes the lines I want to process […]
- Convert RGB to Black & White in OpenCV I would like to know how to convert an RGB image into a black & white (binary) image.
After conversion, how can I save the modified image to disk? Asked By - […]
- OpenCV C++/Obj-C: Detecting a sheet of paper / Square Detection I successfully implemented the OpenCV square-detection example in my test application, but now need to filter the output, because it's quiet messy - or is my code wrong?
I'm interested in […]