Let us do some more image processing in openCV. In this turorial we will do Dilate/Erode operation. This is a basic Morphological Operations. To learn more about Morphological Operations I have found a very good tutorial. You can find it here
Now we will use function Erode ( - Erodes image by using arbitrary structuring element and) Dilate -(Dilates image by using arbitrary structuring element).
lets learn a bit about functions -
NOTE:- Both functions supports the in-place mode. Erosion can be applied several (
After enough learning lets write a program :-
Now we will use function Erode ( - Erodes image by using arbitrary structuring element and) Dilate -(Dilates image by using arbitrary structuring element).
lets learn a bit about functions -
void cvErode( const CvArr* src, CvArr* dst, IplConvKernel* element=NULL, int iterations=1 );
- src
- Source image.
- dst
- Destination image.
- element
- Structuring element used for erosion. If it is
NULL
, a 3×3 rectangular structuring element is used. - iterations
- Number of times erosion is applied.
cvErode
erodes the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the minimum is taken:void cvDilate( const CvArr* src, CvArr* dst, IplConvKernel* element=NULL, int iterations=1 );
- src
- Source image.
- dst
- Destination image.
- element
- Structuring element used for erosion. If it is
NULL
, a 3×3 rectangular structuring element is used. - iterations
- Number of times erosion is applied.
cvDilate
dilates the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the maximum is taken:NOTE:- Both functions supports the in-place mode. Erosion can be applied several (
iterations
) times. In case of color image each channel is processed independently.After enough learning lets write a program :-
#include "cxcore.h"
#include "highgui.h"
int main()
{
IplImage* newImg = NULL;
IplImage* dilateImg = NULL;
IplImage* erodeImg = NULL;
cvNamedWindow("src", 1);
cvNamedWindow("dilate",1);
cvNamedWindow("erode",1);
//load original image
newImg = cvLoadImage("apple.bmp",1);
cvShowImage( "src", newImg );
//make a copy of the original image
dilateImg=cvCloneImage( newImg );
erodeImg=cvCloneImage( newImg );
//dilate image
cvDilate(newImg,dilateImg,NULL,4);
//erode image
cvErode(newImg,erodeImg,NULL,4);
cvShowImage( "dilate", dilateImg );
cvShowImage( "erode", erodeImg );
cvWaitKey(0);
cvDestroyWindow( "src" ); cvDestroyWindow( "dilate" ); cvDestroyWindow( "erode" );
cvReleaseImage( &newImg ); cvReleaseImage( &dilateImg ); cvReleaseImage( &erodeImg );
return 0;
}
Will you pls send me the codes for this ieee paper
ReplyDelete"Efficient Compression for Encrypted Grayscale Images"
Email: taskpro4@gmail.com