Home > code, ImageProcessing, OpenCv > OpenCv; Small Code using Erode and Dilate

OpenCv; Small Code using Erode and Dilate

Small Code that reads pbm image, convert it into 1 channel image. Erodes it, dilates it and shows them

#include <float.h>
#include <limits.h>
#include <time.h>
#include <ctype.h>
#include <iostream>
#include "BlobResult.h"
#include "blob.h"

#ifdef _EiC

#define WIN32

#endif

using namespace std;

void main(void){

IplImage *inputImage = cvLoadImage( "0584.pbm", 1 );

IplImage *gray = cvCreateImage( cvSize(inputImage->width,inputImage->height), 8, 1 );

cvCvtColor( inputImage, gray, CV_BGR2GRAY );

IplImage*img = inputImage;

inputImage = gray;

::cvReleaseImage(&img);

cvNamedWindow( "orig", 1 );

cvShowImage( "orig", inputImage );

IplImage *outputImage;

IplImage *outputImage2;

outputImage = cvCreateImage( cvSize( inputImage->width, inputImage->height ), IPL_DEPTH_8U, 1 );

outputImage2 = cvCreateImage( cvSize( inputImage->width, inputImage->height ), IPL_DEPTH_8U, 1 );

cvErode(inputImage, outputImage, 0, 1);

cvNamedWindow( "erode", 1 );

cvShowImage( "erode", outputImage );

cvDilate(outputImage, outputImage2, 0, 2);

cvNamedWindow( "dilate", 1 );

cvShowImage( "dilate", outputImage2 );

cvReleaseImage(&outputImage);

cvReleaseImage(&outputImage2);

cvWaitKey();

return;

}
Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: