Here is the original image which I am going to filter using above methods.
![]() |
///////////////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include <cv.h>
#include <highgui.h>
int main()
{
//display the original image
IplImage* img = cvLoadImage("C:/MyPic.jpg");
cvNamedWindow("MyWindow");
cvShowImage("MyWindow", img);
//dilate and display the dilated image
cvDilate(img, img, 0, 2);
cvNamedWindow("Dilated");
cvShowImage("Dilated", img);
cvWaitKey(0);
//cleaning up
cvDestroyWindow("MyWindow");
cvDestroyWindow("Dilated");
cvReleaseImage(&img);
return 0;
}
///////////////////////////////////////////////////////////////////////////////////////
You can download this OpenCV visual c++ project from here.
![]() |
Dilated Image |
- cvDilate(img, img, 0, 2)
The 1st parameter is the source image.
The 2nd parameter is the destination image which is to be the dilated image.
The 2nd parameter is the destination image which is to be the dilated image.
Here the 3rd parameter is the structuring element used for dilation. If it is
0
, a 3×3 rectangular structuring element is used.
The 4th parameter is the number of times, dilation is applied.
This function can process images in place. That means same variable can be used for the 1st and 2nd parameters.
dilate ( src, dest, getStructuringElement(MORPH_RECT,Size(3,3)) );
ReplyDeletevery helpful thank you so much
ReplyDeletecan you write a code for background subtraction with average method this one is alos change in new opencv c++ api.
by the way thanks again this all code are very very helpful . you are done great job
Why are some of the tutorials written in another version of opencv? Is there any particular reason for this?
ReplyDelete