#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std;
#endif
#include "HalconCpp.h"
using namespace Halcon;
int main (int argc, char *argv[])
{
if (argc != 2)
{
cout << "Usage : " << argv[0] << " 'image' " << endl;
return (-1);
}
HRegion feats, cd2reg;
HImage image (argv[1]),
text1, text2,
mean1, mean2,
histo;
HWindow win;
Hlong nc;
if ((nc = image.CountChannels ()) != 3)
{
cout << argv[1] << " is not a rgb-image " << endl;
return (-2);
}
image.Display (win);
win.SetColor ("green");
cout << "Draw the region of interrest " << endl;
HRegion region = win.DrawRegion ();
text1 = image.TextureLaws ("el", 2, 5);
mean1 = text1.MeanImage (21, 21);
text2 = mean1.TextureLaws ("es", 2, 5);
mean2 = text2.MeanImage (21, 21);
histo = region.Histo2dim (mean1, mean2);
feats = histo.Threshold (1.0, 1000000.0);
win.SetDraw ("fill");
win.SetColor ("red");
feats.Display (win);
cout << "Charakteristics area in red" << endl;
cd2reg = mean1.Class2dimSup (mean2, feats);
win.SetColor ("blue");
cd2reg.Display (win);
cout << "Result of classification in blue " << endl;
win.Click ();
return (0);
}
示例(C)
read_image(&Image,"combine");
open_window(0,0,-1,-1,0,"visible","",&WindowHandle);
disp_image(Image,WindowHandle);
fwrite_string("draw region of interest with the mouse");
fnew_line();
set_color(WindowHandle,"green");
draw_region(&Testreg,draw_region);
/* Texture transformation for 2-dimensional charachteristic */
texture_laws(Image,&T1,"el",2,5);
mean_image(T1,&M1,21,21);
texture_laws(M1,&T2,"es,",2,5);
mean_image(T2,&M2,21,21);
/* 2-dimensinal histogram of the test region */
histo_2dim(Testreg,M1,M2,&Histo);
/* All points occuring at least once */
threshold(Histo,&FeatureSpace,1.0,100000.0);
set_draw(WindowHandle,"fill");
set_color(WindowHandle,"red");
disp_region(FeatureSpace,WindowHandle);
fwrite_string("Characteristics area in red");
fnew_line();
/* Segmentation */
class_2dim_sup(M1,M2,FeatureSpace,&RegionClass2Dim);
set_color(WindowHandle,"blue");
disp_region(RegionClass2Dim,WindowHandle);
fwrite_string("Result of classification in blue");
fnew_line();
示例 (C++ (HALCON 5.0-10.0))
#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std;
#endif
#include "HalconCpp.h"
using namespace Halcon;
int main (int argc, char *argv[])
{
if (argc != 2)
{
cout << "Usage : " << argv[0] << " 'image' " << endl;
return (-1);
}
HRegion feats, cd2reg;
HImage image (argv[1]),
text1, text2,
mean1, mean2,
histo;
HWindow win;
Hlong nc;
if ((nc = image.CountChannels ()) != 3)
{
cout << argv[1] << " is not a rgb-image " << endl;
return (-2);
}
image.Display (win);
win.SetColor ("green");
cout << "Draw the region of interrest " << endl;
HRegion region = win.DrawRegion ();
text1 = image.TextureLaws ("el", 2, 5);
mean1 = text1.MeanImage (21, 21);
text2 = mean1.TextureLaws ("es", 2, 5);
mean2 = text2.MeanImage (21, 21);
histo = region.Histo2dim (mean1, mean2);
feats = histo.Threshold (1.0, 1000000.0);
win.SetDraw ("fill");
win.SetColor ("red");
feats.Display (win);
cout << "Charakteristics area in red" << endl;
cd2reg = mean1.Class2dimSup (mean2, feats);
win.SetColor ("blue");
cd2reg.Display (win);
cout << "Result of classification in blue " << endl;
win.Click ();
return (0);
}
示例 (C++ (HALCON 5.0-10.0))
#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std;
#endif
#include "HalconCpp.h"
using namespace Halcon;
int main (int argc, char *argv[])
{
if (argc != 2)
{
cout << "Usage : " << argv[0] << " 'image' " << endl;
return (-1);
}
HRegion feats, cd2reg;
HImage image (argv[1]),
text1, text2,
mean1, mean2,
histo;
HWindow win;
Hlong nc;
if ((nc = image.CountChannels ()) != 3)
{
cout << argv[1] << " is not a rgb-image " << endl;
return (-2);
}
image.Display (win);
win.SetColor ("green");
cout << "Draw the region of interrest " << endl;
HRegion region = win.DrawRegion ();
text1 = image.TextureLaws ("el", 2, 5);
mean1 = text1.MeanImage (21, 21);
text2 = mean1.TextureLaws ("es", 2, 5);
mean2 = text2.MeanImage (21, 21);
histo = region.Histo2dim (mean1, mean2);
feats = histo.Threshold (1.0, 1000000.0);
win.SetDraw ("fill");
win.SetColor ("red");
feats.Display (win);
cout << "Charakteristics area in red" << endl;
cd2reg = mean1.Class2dimSup (mean2, feats);
win.SetColor ("blue");
cd2reg.Display (win);
cout << "Result of classification in blue " << endl;
win.Click ();
return (0);
}
示例 (C++ (HALCON 5.0-10.0))
#include "HIOStream.h"
#if !defined(USE_IOSTREAM_H)
using namespace std;
#endif
#include "HalconCpp.h"
using namespace Halcon;
int main (int argc, char *argv[])
{
if (argc != 2)
{
cout << "Usage : " << argv[0] << " 'image' " << endl;
return (-1);
}
HRegion feats, cd2reg;
HImage image (argv[1]),
text1, text2,
mean1, mean2,
histo;
HWindow win;
Hlong nc;
if ((nc = image.CountChannels ()) != 3)
{
cout << argv[1] << " is not a rgb-image " << endl;
return (-2);
}
image.Display (win);
win.SetColor ("green");
cout << "Draw the region of interrest " << endl;
HRegion region = win.DrawRegion ();
text1 = image.TextureLaws ("el", 2, 5);
mean1 = text1.MeanImage (21, 21);
text2 = mean1.TextureLaws ("es", 2, 5);
mean2 = text2.MeanImage (21, 21);
histo = region.Histo2dim (mean1, mean2);
feats = histo.Threshold (1.0, 1000000.0);
win.SetDraw ("fill");
win.SetColor ("red");
feats.Display (win);
cout << "Charakteristics area in red" << endl;
cd2reg = mean1.Class2dimSup (mean2, feats);
win.SetColor ("blue");
cd2reg.Display (win);
cout << "Result of classification in blue " << endl;
win.Click ();
return (0);
}