#include "stdafx.h"//binary processing of a picture
Iplimage *psrclmg =null;//Loading pictures
Iplimage *PDECLMG =null;//-generated images
void ontrackerslid (int thresth)
{
/*int i,j,k; Set a threshold value that is equal to 255 if it is greater than the threshold value, which is assigned as 0
int height =pdeclmg->height;
int width =pdeclmg->width;
int step =pdeclmg->widthstep;
int Channels =pdeclmg->nchannels;
Uchar *data0 = (uchar*) (psrclmg->imagedata);
Uchar *data1 = (uchar*) (psrclmg->imagedata);
for (i=0;i{
for (j=0;j<width;j++)
{
for (k=0;k<channels;k++)
{
if (data0[i*step+j+k]>thresth)
data0[i*step+j+k]=255;
Else
data1[i*step+j+k]=0;
}
}
}
Cvshowimage ("Pdeclmg_image", PDECLMG); * *
Convert to binary graph
Cvthreshold (PSRCLMG,PDECLMG, Thresth, 255, cv_thresh_binary);
Show binary graphs
Cvshowimage ("Pdeclmg_image", PDECLMG);
}
int _tmain (int argc,_tchar* argv[])
{
int thresth=127;
PSRCLMG =cvloadimage ("Pavement 4.jpg", 0);
PDECLMG =cvcreateimage (Cvgetsize (PSRCLMG), 8, 1);
Cvshowimage ("Source_image", PSRCLMG);
Pdeclmg=cvcloneimage (PSRCLMG);
Cvnamedwindow ("Source_image", cv_window_autosize);
Cvnamedwindow ("Pdeclmg_image", 0);
Cvcreatetrackbar ("Threshold", "pdeclmg_image", &thresth,255,ontrackerslid);
Ontrackerslid (THRESTH);
Cvsaveimage ("e:\\ material \ \ Road 5.jpg", PDECLMG);
Cvwaitkey (0);
Cvdestroywindow ("Source_image");
Cvdestroywindow ("Pdeclmg_image");
Cvreleaseimage (&PSRCLMG);
Cvreleaseimage (&PDECLMG);
return 0;
}
OPENCV Two value processing