Please help me. First, this is original/source picture. (Picture 1)
with canny and morphology, I processing picture from that original picture like this (Picture 2) :
And now, I want to process the image so that it looks like this (Picture 3) :
But I don't know how to make them into images like that (Picture 3). Plese help me. Can you give me the source code to make it like Picture 3 ?
This is my source code (Convert Picture 1 to Picture 2) :
// Area_Daun.cpp : main project file.
include "stdafx.h"
include "cxcore.h"
include "highgui.h"
include "cv.h"
include "stdio.h"
using namespace System;
int main() { IplImage* img = NULL; IplImage* OpenImg = NULL;
//load original image
img = cvLoadImage("kubis2.jpg");
IplImage* newImg = cvCreateImage (cvGetSize(img), IPL_DEPTH_8U,1);
IplImage* newImg1 = cvCreateImage (cvGetSize(img), IPL_DEPTH_8U,1);
IplImage* newImg2 = cvCreateImage (cvGetSize(img), IPL_DEPTH_8U,1);
CvMat *mat= cvCreateMat(newImg->height, newImg->width, CV_64FC1);
CvMat *mat1= cvCreateMat(newImg->height, newImg->width, CV_64FC1);
CvMat *mat2= cvCreateMat(newImg->height, newImg->width, CV_64FC1);
cvCvtColor(img,newImg,CV_RGB2GRAY);
cvThreshold(newImg, newImg, 200,255,CV_THRESH_BINARY_INV);
cvConvert(newImg, mat);
cvCanny(newImg,newImg1,1,1,3);
cvConvert(newImg1, mat1);
cvMorphologyEx( newImg, newImg2, 0, 0, CV_MOP_OPEN, 3);
cvConvert(newImg2, mat2);
float putih1 = 0;
for(int x=0; x<newImg->height; x++){
for(int y=0; y<newImg->width; y++)
{
if (cvmGet (mat,x,y)==255){
putih1++;
}
}
}
printf("Luas Daerah Citra / Area Yang Rusak: %.0f\n",putih1);
/*float putih2 =0;
for(int x=0; x<newImg1->height; x++){
for(int y=0; y<newImg1->width; y++)
{
if (cvmGet (mat1,x,y)==255){
putih2++;
}
}
}
printf("Perimeter : %.0f\n",putih2);
*/
/*float putih3 =0;
for(int x=0; x<newImg2->height; x++){
for(int y=0; y<newImg2->width; y++)
{
if (cvmGet (mat2,x,y)==255){
putih3++;
}
}
}
float rasio = putih3/putih1;
printf("Rasio Area Citra : %f",rasio);
*/
cvShowImage( "original", img );
cvShowImage( "src", newImg );
cvShowImage( "canny", newImg1 );
//cvShowImage( "opening", newImg2 );
cvWaitKey(0);
return 0;
}