基于相关系数影像匹配实习报告 - 图文(2)

2019-08-20 20:40

if (biBitCount == 8) { bmfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + 256*4; bmfh.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + 256*4 + byteCount; } else if (biBitCount == 24) { bmfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); bmfh.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + byteCount; } else { MessageBox(NULL, \错误\ return; } bmih.biBitCount = biBitCount; bmih.biWidth = width; bmih.biHeight = height; bmih.biSize = 40; bmih.biPlanes = 1; bmih.biCompression = BI_RGB; bmih.biSizeImage = bmfh.bfSize; bmih.biClrImportant = 0; bmih.biClrUsed = 0; bmih.biXPelsPerMeter = 0; bmih.biYPelsPerMeter = 0; CFile f; //保存位图 if (f.Open(SavePath, CFile::modeCreate | CFile::modeWrite)) { f.Write(&bmfh, sizeof(bmfh)); f.Write(&bmih, sizeof(bmih)); if (biBitCount == 8) { RGBQUAD rgb[256]; int i(0); for (; i < 256; ++i) { rgb[i].rgbBlue = i; rgb[i].rgbGreen = i; rgb[i].rgbRed = i;

rgb[i].rgbReserved = 0; } //修改颜色表255对应的颜色 rgb[255].rgbBlue = 0; rgb[255].rgbGreen = 0; rgb[255].rgbRed = 255; f.Write(rgb, sizeof(RGBQUAD)*256); } f.Write(pBits, byteCount); f.Close(); } else { MessageBox(NULL, \保存图像失败\错误\ return; } }

void DrawCross(BYTE* pBits, vector FeaturePoint, int _width, int byteCount) { vector::iterator iter; int i(0), j(0); for (i = 0; i < byteCount; ++i) { if (pBits[i] == 255) pBits[i] = 254; } for (iter = FeaturePoint.begin(); iter != FeaturePoint.end(); ++iter) { i = iter->y; j = iter->x; pBits[i*_width+j] = 255; pBits[i*_width+j+1] = 255; pBits[i*_width+j-1] = 255; pBits[(i+1)*_width+j] = 255; pBits[(i-1)*_width+j] = 255; pBits[i*_width+j+2] = 255; pBits[i*_width+j-2] = 255; pBits[(i+2)*_width+j] = 255; pBits[(i-2)*_width+j] = 255; } }

void DrawCross(BYTE* pBits1, BYTE* pBits2, vector MatchedPoints, int _width1, int _width2, int byteCount1, int byteCount2) { vector::iterator iter; int i(0), j(0); for (i = 0; i < byteCount1; ++i) { if (pBits1[i] == 255) pBits1[i] = 254; } for (j = 0; j < byteCount2; ++j) { if (pBits2[j] == 255) pBits2[j] = 254; } for (iter = MatchedPoints.begin(); iter != MatchedPoints.end(); ++iter) { i = iter->y1; j = iter->x1; pBits1[i*_width1+j] = 255; pBits1[i*_width1+j+1] = 255; pBits1[i*_width1+j-1] = 255; pBits1[(i+1)*_width1+j] = 255; pBits1[(i-1)*_width1+j] = 255; pBits1[i*_width1+j+2] = 255; pBits1[i*_width1+j-2] = 255; pBits1[(i+2)*_width1+j] = 255; pBits1[(i-2)*_width1+j] = 255; i = iter->y2; j = iter->x2; pBits2[i*_width2+j] = 255; // pBits2[i*_width2+j+1] = 255; pBits2[i*_width2+j-1] = 255; pBits2[(i+1)*_width2+j] = 255; pBits2[(i-1)*_width2+j] = 255; pBits2[i*_width2+j+2] = 255; pBits2[i*_width2+j-2] = 255; pBits2[(i+2)*_width2+j] = 255; pBits2[(i-2)*_width2+j] = 255; } }

void SaveList(vector FeaturePoint, CString txtFile)

{ FILE* pTxtFile= fopen(txtFile, \ if (!pTxtFile) return; fprintf(pTxtFile, \特征点数: %d\\n\\n\ fprintf(pTxtFile, \坐标X\\t坐标Y\\t兴趣值\\n\ vector::iterator iter; for (iter = FeaturePoint.begin(); iter != FeaturePoint.end(); ++iter) fprintf(pTxtFile, \ fclose(pTxtFile); }

void SaveList(vector MatchedPoints, CString txtFile) { FILE* pTxtFile= fopen(txtFile, \ if (!pTxtFile) return; fprintf(pTxtFile, \同名点对数: %d\\n\\n\ vector::iterator iter; for (iter = MatchedPoints.begin(); iter != MatchedPoints.end(); ++iter) fprintf(pTxtFile, \ iter->x1, iter->y1, iter->x2, iter->y2, iter->coefficient); fclose(pTxtFile); }

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { if (argc != 15) { ::MessageBox(NULL,\启动参数不正确,请从GUI.exe或命令行参数启动\ return FAILURE; } system(\ system(\ int nRetCode = 0; if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) { cerr << _T(\ nRetCode = 1; return nRetCode; } CString srcFileLeft, srcFileRight, dstFileLeft, dstFileRight, txtFile; CString threshold_Left,window1_Left,window2_Left; CString threshold_Right,window1_Right,window2_Right; CString CoRelated,window3,flag1; //启动参数

srcFileLeft = argv[1]; srcFileRight = argv[2]; dstFileLeft = argv[3]; dstFileRight = argv[4]; txtFile = argv[5];

threshold_Left = argv[6]; //阈值 window1_Left = argv[7]; window2_Left = argv[8]; threshold_Right = argv[9]; window1_Right = argv[10]; window2_Right = argv[11]; CoRelated = argv[12]; window3 = argv[13]; flag1 = argv[14]; //判断是否在创建结果文件后显示 int m_threshold_L = atoi(threshold_Left); int m_window1_L = atoi(window1_Left); int m_window2_L = atoi(window2_Left); int m_threshold_R = atoi(threshold_Right); int m_window1_R = atoi(window1_Right); int m_window2_R = atoi(window2_Right);

double m_CoRelated = (double)atoi(CoRelated) / 100; int m_window3 = atoi(window3); int m_flag1 = atoi(flag1);

if (GetFileAttributes(srcFileLeft) == -1) { CString err; err.Format(\文件:%s不存在\ ::MessageBox(NULL,err, \ return FAILURE; }

if (GetFileAttributes(srcFileRight) == -1) { CString err; err.Format(\文件:%s不存在\ ::MessageBox(NULL,err, \ return FAILURE; }

//打开2幅影像

FILE* pSrcFileLeft = NULL;

pSrcFileLeft = fopen(srcFileLeft,\if(pSrcFileLeft == NULL) { printf(\原始左片影像打开失败\\n\


基于相关系数影像匹配实习报告 - 图文(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:浙教版七下数学第4章《因式分解》单元培优测试题

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: