OPENCV Two value processing

Source: Internet
Author: User

#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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.