資源簡介
計算兩幅單波段影像之間的偏差指數,可用于影像融合質量評價

代碼片段和文件信息
#include?
#include?
#include?
#define?WIDTHBYTES(i)?(((i)?+?31)?/?32?*?4)
//(nImageWidth*nBitCount+31)/32*4 i?=?nImageWidth*nBitCount
//讀取2副真彩色位圖,分別求3個波段對應的偏差指數
void?main(int?char?**?char?**)
{
FILE*?pFile?=?fopen(“D:\\desktop\\融合數據\\TEST.bmp“?“rb“); //here?is?the?fusion?image
if?(!pFile)
{
printf(“Oh\n“);
return;
}
fseek(pFile?14?SEEK_SET);
BITMAPINFOHEADER?bmih;
fread(&bmih?sizeof(bmih)?1?pFile);
if?(bmih.biBitCount?!=?24)
{
printf(“I?can‘t?accept?you?for?you?are?not?my?taste\n“);
return;
}
int?m_width?=?bmih.biWidth;
int?m_height?=?bmih.biHeight;
int?width?=?WIDTHBYTES(m_width*24);
fseek(pFile?1024?SEEK_CUR);
LPBYTE?pBits1?=?new?BYTE[width*m_height];
fread(pBits1?width*m_height?1?pFile);
fclose(pFile);
pFile?=?fopen(“D:\\desktop\\融合數據\\color-berkeley.bmp“?“rb“);
if?(!pFile)
{
printf(“Oh?again\n“);
return;
}
fseek(pFile?14?SEEK_SET);
fread(&bmih?sizeof(bmih)?1?pFile);
if?(bmih.biBitCount?!=?24)
{
printf(“I?can‘t?accept?you?for?you?are?not?my?taste?BABY\n“);
return;
}
if?(bmih.biWidth?!=?m_width?||?bmih.biHeight?!=?m_height)
{
printf(“You?are?not?the?one?he?is?waiting?for\n“);
return;
}
fseek(pFile?1024?SEEK_CUR);
LPBYTE?pBits2?=?new?BYTE[width*m_height];
fread(pBits2?width*m_height?1?pFile);
fclose(pFile);
//read?data?done
double?DI[3]?=?{0};
int?i(0)?j(0);
LPBYTE?p1?=?pBits1;
LPBYTE?p2?=?pBits2; //copy?of?origin?pointer
for?(;?i? {
p1?=?pBits1?+?i*width;
p2?=?pBits2?+?i*width;
for?(j?=?0;?j? {
if?(*(p1+3*j+0)?!=?0)
DI[0]?+=?fabs(?(?*(p1+3*j+0)?-?*(p2+3*j+0)?)?/?(*(p1+3*j+0))?); //分母為融合影像
if?(*(p1+3*j+1)?!=?0)
DI[1]?+=?fabs(?(?*(p1+3*j+1)?-?*(p2+3*j+1)?)?/?(*(p1+3*j+1))?); //分母為融合影像
if?(*(p1+3*j+2)?!=?0)
DI[2]?+=?fabs(?(?*(p1+3*j+2)?-?*(p2+3*j+2)?)?/?(*(p1+3*j+2))?); //分母為融合影像
}
}
delete[]?pBits1;
pBits1?=?NULL;
delete[]?pBits2;
pBits2?=?NULL;
DI[0]?/=?(m_width*m_height);
DI[1]?/=?(m_width*m_height);
DI[2]?/=?(m_width*m_height);
printf(“%f\n%f\n%f\n“?DI[0]?DI[1]?DI[2]);
return;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2285??2011-03-21?13:32??DeviationIndex.cpp
?????文件???????4380??2011-03-20?21:55??DeviationIndex.dsp
?????文件????????553??2011-03-20?21:52??DeviationIndex.dsw
?????文件??????????0??2012-02-17?15:42??求取2幅影像指定波段之間偏差系數.txt
-----------?---------??----------?-----??----
?????????????????7218????????????????????4
- 上一篇:根據衛星星歷結算GPS衛星位置
- 下一篇:KL變換主分量變換處理位圖格式的影像
評論
共有 條評論