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?
ReplyDeleteusing namespace cv;
Deleteusing namespace std;
int main(int argc, char** argv)
{
// Read the image file
Mat image = imread("C:\\Users\\SIF\\source\\repos\\ConsoleApplication1\\ConsoleApplication1\\Car.jpg");
// Check for failure
if (image.empty())
{
cout << "Could not open or find the image" << endl;
cin.get(); //wait for any key press
return -1;
}
//Erode the image with 3x3 kernel
Mat image_eroded_with_3x3_kernel;
dilate (image, image_eroded_with_3x3_kernel, getStructuringElement(MORPH_DILATE, Size(3, 3)));
//erode(image, image_eroded_with_3x3_kernel, getStructuringElement(MORPH_DILATE, Size(3, 3)));
//Erode the image with 5x5 kernel
Mat image_eroded_with_5x5_kernel;
dilate(image, image_eroded_with_5x5_kernel, getStructuringElement(MORPH_RECT, Size(5, 5)));
//Define names of the windows
String window_name = "Lotus";
String window_name_eroded_with_3x3_kernel = "Lotus eroded with 3 x 3 kernel";
String window_name_eroded_with_5x5_kernel = "Lotus eroded with 5 x 5 kernel";
// Create windows with above names
namedWindow(window_name);
namedWindow(window_name_eroded_with_3x3_kernel);
namedWindow(window_name_eroded_with_5x5_kernel);
// Show our images inside the created windows.
imshow(window_name, image);
imshow(window_name_eroded_with_3x3_kernel, image_eroded_with_3x3_kernel);
imshow(window_name_eroded_with_5x5_kernel, image_eroded_with_5x5_kernel);
waitKey(0); // Wait for any keystroke in the window
destroyAllWindows(); //destroy all opened windows
return 0;
}
koop rijbewijs online geregistreerd in de gemeente binnen 5 tot 7 werkdagen tegen een goedkope prijs zonder examens
ReplyDeleteRijbewijs Kopen België
Rijbewijs Kopen
Rijbewijs b Kopen
Rijbewijs Online Kopen
Comprar carta conducao online sem exames no prazo de 5 a 7 dias úteis válido no imt de portugal
ReplyDeleteComprar Carta Condução
carta condução mota
kjøpe førerkort
buy UK driver's license
Comprar Carta de Condução
Carta de Condução Preços
Comprar Carta Condução Verdadeira
Comprar Carta de Mota
Führerschein in Deutschland im Datenbanksystem registriert ohne Prüfungen innerhalb von 5 bis 7 Werktagen kaufen
ReplyDeleteFührerschein kaufen
eu führerschein kaufen
registrierten Führerschein kaufen
echten führerschein kaufen
deutschen Führerschein kaufen
führerschein kaufen legal
Acquista la patente di guida sul nostro sito Web valida nel sistema di database senza esami entro 5-7 giorni lavorativi
ReplyDeletecomprare patente
acquisti la patente guida
come acquistare patente guida
kup prawo jazdy
Comprar Carta de Condução
acheter permis de conduire
köp körkort
acquiste patente di guida
Comprar carnet de conducir en nuestra web inscrito en el Dgt en un plazo de 5 a 7 días hábiles sin exámenes y podrá conducir libremente en España y otros países sin ningún problema señor
ReplyDeleteComprar Licencia de Conducir
Comprar Carnet de Conducir
Comprar Licencia Conducir Legal
Comprar carnet de conducir
comprar licencias de conducir
comprar carnet conducir dgt
comprar licencia de conducir
Cum să cumpărați permisul de conducere online în 5 până la 7 zile fără examene
ReplyDeletecumpăra permis de conducere
cumpărați permisul conducere online
cumpara permis conducere romanesc
cumpăra permis conducere înregistrat
cumpăra permis conducere România