生活随笔
收集整理的這篇文章主要介紹了
Opencv 图像增强算法 图像检测结果及代码
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
******************************************************************************************************************************************
紅:數字圖像處理視頻教程(兩部)
{中科院版36講視頻教程 + 電子科大版70講視頻教程(岡薩雷斯 第二版)}
? ? 橙:halcon軟件、halcon軟件手把手教破解視頻教程
? ? 黃:數字圖像模式識別demo(C++編寫,在公司也是用C++哦)
? ? 綠:halcon軟件視頻教程、halcon軟件在vs2010中配置
? ? 青:面向對象C++視頻教程
? ? 藍:MFC C++視頻教程
? ? 紫:海量相關文檔資料
? ? http://item.taobao.com/item.htm?spm=a1z10.3.w4002-9510581636.11.VUYzOY&id=43025290175
******************************************************************************************************************************************
本code通過直方圖變換增強了圖像對比度,實現了單通道圖像增強。將圖像灰度閾值拉伸到0-255,圖像檢測結果見底部
Keywords: 圖像增強 增強對比度 直方圖變換
[cpp]?view plaincopy
int?ImageStretchByHistogram(IplImage?*src1,IplImage?*dst1)?? ? ? ? ? ?? {?? ????assert(src1->width==dst1->width);?? ????double?p[256],p1[256],num[256];?? ?????? ????memset(p,0,sizeof(p));?? ????memset(p1,0,sizeof(p1));?? ????memset(num,0,sizeof(num));?? ????int?height=src1->height;?? ????int?width=src1->width;?? ????long?wMulh?=?height?*?width;?? ?????? ?????? ????for(int?x=0;x<src1->width;x++)?? ????{?? ????????for(int?y=0;y<src1->?height;y++){?? ????????????uchar?v=((uchar*)(src1->imageData?+?src1->widthStep*y))[x];?? ????????????????num[v]++;?? ????????}?? ????}?? ?????? ????for(int?i=0;i<256;i++)?? ????{?? ????????p[i]=num[i]/wMulh;?? ????}?? ?? ?????? ????for(int?i=0;i<256;i++)?? ????{?? ????????for(int?k=0;k<=i;k++)?? ????????????p1[i]+=p[k];?? ????}?? ?? ?????? ????for(int?x=0;x<src1->width;x++)?? ????{?? ????????for(int?y=0;y<src1->?height;y++){?? ????????????uchar?v=((uchar*)(src1->imageData?+?src1->widthStep*y))[x];?? ????????????????((uchar*)(dst1->imageData?+?dst1->widthStep*y))[x]=?p1[v]*255+0.5;?????????????? ????????}?? ????}?? ????return?0;?? }?? ?? void?CCVMFCView::OnImageAdjustContrast()?? {?? ????if(workImg->nChannels>1)?? ????????OnColorToGray();?? ????Invalidate();?? ????dst=cvCreateImage(cvGetSize(workImg),workImg->depth,workImg->nChannels);?? ????ImageStretchByHistogram(workImg,dst);?? ????m_dibFlag=imageReplace(dst,&workImg);?? ????Invalidate();?? }??
Experiment Result:
? ? ? ? ? ? ? ??? ? ? ??? ? ? ? ? ? 原圖灰度化
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?檢測結果1
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 灰度化并增強對比度
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?檢測結果2
總結
以上是生活随笔為你收集整理的Opencv 图像增强算法 图像检测结果及代码的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。