資源簡介
對目標的顏色進行識別,通過相應的軟件進行處理,來達到要求。
代碼片段和文件信息
#include
#include?
#include?
#include?
#include?
#include????//malloc?need
#include?
using?namespace?std;
#define?width?60
#define?height?80
double?normal[width][height];
?//圖像矩陣歸一化處理
?double?normalization(double?x??int?max)
?{
return?(x-0)/max*256;
?}
??//圖像矩陣歸一化處理1
?double?normalization1(double?x?)
?{
return?(x-0)/(32*0.11+64*0.59+32*0.3)*256;
?}
??
//將數據轉換為二進制
?string?HexToBin(const?string?&strHex)
?{
?????string?strBins;
?const?string?m=“0000“;
?int?a;
?for(int?i=0?;?i?4?;i++)??//測試用的是兩個字符
?{
?if(strHex[i]>=‘0‘&&strHex[i]<=‘9‘)
?{a?=?(int)?strHex[i]-48;}
?else?a?=?(int)?strHex[i]-55;
?for(s?=?““;a?;?a=?a/2)
?{
s?=?s?+?(a%2?‘1‘:‘0‘);
?}
??if(4!=s.size())
?{
s.append(?m04-s.size());
?}
?reverse?(s.begin(?)?s.end(?)?);
?strBin.append(s);
?}
????return?strBin;
?}
//這是16位表示一個RGB值的轉換
void?ceshizhuanhuan(){
string?c8c9;
char*?yyy?;
int?aaaaa?;
ifstream?in(“壓縮圖片.txt“);
ofstream?out;
out.open(“huidutupian.txt“);
if(!in)
{
cerr< }
if(!in.eof())
{
//in>>mm;
//cout< for(int?i?=?0?;?i? {
for(int?j?=?0?;?j? {
if(!in.eof())
{
in>>c8;
in>>c9;
c8.append(c9);
c9=HexToBin(c8);??//轉化為二進制
yyy?=?(char*)c9.data();
aaaaa?=?(int)strtol(yyy??NULL??2);
out< normal[i][j]=aaaaa;
}
}
}
}
out.close();
}
//圖像的自適應二值化“十字矩陣二值化算法”
void?self_binaryzation()
{
double?binary[width][height];
ofstream?out;
out.open(“binary.txt“);
int?y=(int)sqrt(width*(width+height)/height);
int?x=y*height/width;
for(int?i=0;i {
for(int?j=0;j {
?????????int?sss=0y1=0y2=0x1=0x2=0;
?y1=i-y/2;
?y2=i+y/2;
?x1=j-x/2;
?x2=j+x/2;
?if(y1<0)?y1=0;
?if(x1<0)?x1=0;
?if(y2>width)?y2=width;
?if(x2>height)?x2=height;
for(int?m=y1;m ???????????????for(int?n=x1;n ???sss+=normal[m][n];
sss/=((y2-y1)*(x2-x1));
if(normal[i][j] binary[i][j]=0;
else?
binary[i][j]=255;
out<
}
}
out<
}
?//數據轉換得到灰度圖
void?zhuanhuan()
?{
//int?mm=1;
int?a??b??c?;
double?d;
string?c1c2c3;
char*?p?;
char*?q;
char*?r;
ifstream?in(“乒乓9左側.txt“);
ofstream?rout;
rout.open(“r.txt“);
ofstream?gout;
gout.open(“g.txt“);
ofstream?bout;
bout.open(“b.txt“);
ofstream?Hout;
Hout.open(“huidu.txt“);
if(!in)
{
cerr< }
if(!in.eof())
{
//in>>mm;
//cout< for(int?i?=?0?;?i? {
for(int?j?=?0?;?j? {
if(!in.eof())
{
in>>c1;
in>>c2;
c1.append(c2);
c2=HexToBin(c1);??//轉化為二進制
c3=c2.substr(05);
p?=?(char*)c3
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-05-03?09:25??RGB圖像處理\
?????目錄???????????0??2019-05-03?09:25??RGB圖像處理\Image_process\
?????文件???????24050??2018-01-27?16:41??RGB圖像處理\Image_process\b.txt
?????文件???????28730??2018-01-27?16:41??RGB圖像處理\Image_process\binary.txt
?????目錄???????????0??2019-05-03?09:25??RGB圖像處理\Image_process\Debug\
?????文件??????287744??2018-01-27?16:41??RGB圖像處理\Image_process\Debug\image.bsc
?????文件??????585767??2018-01-27?16:41??RGB圖像處理\Image_process\Debug\image.exe
?????文件??????832096??2018-01-27?16:41??RGB圖像處理\Image_process\Debug\image.ilk
?????文件??????317355??2018-01-27?16:41??RGB圖像處理\Image_process\Debug\image.obj
?????文件?????2883548??2018-01-24?13:14??RGB圖像處理\Image_process\Debug\image.pch
?????文件?????1147904??2018-01-27?16:41??RGB圖像處理\Image_process\Debug\image.pdb
?????文件???????????0??2018-01-27?16:41??RGB圖像處理\Image_process\Debug\image.sbr
?????文件??????287744??2018-01-23?22:55??RGB圖像處理\Image_process\Debug\MAG.bsc
?????文件??????585765??2018-01-23?22:55??RGB圖像處理\Image_process\Debug\MAG.exe
?????文件??????832624??2018-01-23?22:55??RGB圖像處理\Image_process\Debug\MAG.ilk
?????文件?????2883548??2018-01-23?19:58??RGB圖像處理\Image_process\Debug\MAG.pch
?????文件?????1172480??2018-01-23?22:55??RGB圖像處理\Image_process\Debug\MAG.pdb
?????文件???????82944??2018-01-27?16:41??RGB圖像處理\Image_process\Debug\vc60.idb
?????文件??????110592??2018-01-27?16:41??RGB圖像處理\Image_process\Debug\vc60.pdb
?????文件???????24101??2018-01-27?16:41??RGB圖像處理\Image_process\g.txt
?????文件???????38481??2018-01-27?16:41??RGB圖像處理\Image_process\huidu.txt
?????文件??????527517??2018-01-23?20:20??RGB圖像處理\Image_process\huidutupian.txt
?????文件????????3870??2018-01-27?16:41??RGB圖像處理\Image_process\image.cpp
?????文件????????3393??2018-01-24?14:17??RGB圖像處理\Image_process\image.dsp
?????文件?????????533??2018-01-24?14:17??RGB圖像處理\Image_process\image.dsw
?????文件?????????482??2018-01-23?19:42??RGB圖像處理\Image_process\image.h
?????文件???????41984??2018-01-27?17:06??RGB圖像處理\Image_process\image.ncb
?????文件???????48640??2018-01-27?17:06??RGB圖像處理\Image_process\image.opt
?????文件????????1352??2018-01-27?16:41??RGB圖像處理\Image_process\image.plg
?????文件????????4314??2018-01-23?22:57??RGB圖像處理\Image_process\MAG.dsp
?????文件?????????529??2018-01-23?19:42??RGB圖像處理\Image_process\MAG.dsw
............此處省略307個文件信息
- 上一篇:基于FPGA的黑白棋小游戲
- 下一篇:彩虹3引擎1012版注冊機
評論
共有 條評論