91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 14KB
    文件類型: .cpp
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2022-11-11
  • 語言: C/C++
  • 標(biāo)簽: 圖像修復(fù)??

資源簡介

對(duì)于受損的圖像可以通過算法將其還原,因?yàn)橛玫降氖菑耐馊Φ嚼锶Φ闹饘有迯?fù),所以修復(fù)效果比較不錯(cuò),可以通過對(duì)PSNR值的計(jì)算,得到圖像修復(fù)的好壞。

資源截圖

代碼片段和文件信息

#include?
#include?
#include?
#include?
#include?
#include??
?
#ifdef?_CH_
#pragma?package?
#endif

?
IplImage*?img0?=?0?*img?=?0?*mask?=?0*abc*abc0;
IplImage*?Img_repair=0;
IplImage*?Img_cvrepair=0;
IplImage*?Mask=0;
IplImage*?Abc=0;
IplImage*?Mask0=0;
CvPoint?prev_pt?=?{-1-1};

struct?node{??????????????????????????????????????????????????????????????
??int?x;
??int?y;
??int?px[3];
??struct?node?*pNext;

};

void?on_mouse(?int?event?int?x?int?y?int?flags?void*?zhang)
{

if?(?!img?)
return;
?
if?(event?==?CV_EVENT_LBUTTONUP?||?!(flags?&?CV_EVENT_FLAG_LBUTTON)?)
prev_pt?=?cvPoint(-1-1);
else?if?(event?==?CV_EVENT_LBUTTONDOWN)
prev_pt?=?cvPoint(xy);
else?if?(event?==?CV_EVENT_MOUSEMOVE?&&?(flags?&?CV_EVENT_FLAG_LBUTTON)?)
{
????????CvPoint?pt?=?cvPoint(xy);
????????if?(prev_pt.x??????????????prev_pt?=?pt;
????????cvLine(img?prev_pt?pt?CV_RGB(255?255?255)?5);
????????cvLine(mask?prev_pt?pt?cvScalarAll(255)?5?8);
????????prev_pt?=?pt;
????????cvShowImage(“Damaged?Image“?img?);
?
????}
}

void?psnr(IplImage*?src1?IplImage*?src2)
{
int?h1?=?src1->height;
int?w1?=?src1->width;
int?c1?=?src1->nChannels;

int?h2?=?src2->height;
int?w2?=?src2->width;
int?c2?=?src2->nChannels;

????int?step;
int?i?j?k;
double?sub;
double?mse?=?0;
double?psnr_value;

uchar?*data1;
uchar?*data2;



if?(?(h1?!=?h2)?||?(w1?!=?w2)?||?(c1?!=?c2)?)
{
printf(“Warning?:?The?dimension?of?two?input?images?must?be?the?same!\n\n“);
}
else
{
step??=?src1->widthStep;
data1?=?(uchar?*)src1->imageData;
data2?=?(uchar?*)src2->imageData;

for?(?i?=?0;?i? {
for?(?j?=?0;?j? {
for?(?k?=?0;?k? {
sub?=?abs(data1[i*step+j*c1+k]?-?data2[i*step+j*c2+k]);
mse?=?mse?+?pow(sub?2);
}
}
}

if?(mse?==?0)
{
printf(“PSNR?is?infinite.?They?may?be?the?same?images.\n\n“);
}

else
{
mse?=?mse/h1/w1/c1;
psnr_value?=?10*log10(pow(255.0?2)/mse);
printf(“PSNR?=?%.2f?dB\n\n“?psnr_value);
}

}
}

struct?node?*Get_Px?(IplImage*?Img)?????????????????????????????????????//創(chuàng)建結(jié)構(gòu)體儲(chǔ)存外圍壞點(diǎn)位置
{????????
?int?k=0;
?bool?one=falsetwo=false;
?uchar?*Data=(uchar?*)Img->imageData;
?int?step_mark=Img->widthStep/sizeof(uchar);
?struct?node?*pHead=NULL*pPail=NULL;
?for?(int?i=0;?iheight;?i++)?
{
???for?(int?j=0;?jwidth;?j++)?
???{
???????one=(i==0)||(j==0)||(i==(Img->height-1))||(j==(Img->width-1));????????//判斷是否為最外圍像素
???if(one==false)?????
??two=(Data[i*step_mark+j-1]==0)||(Data[i*step_mark+j+1]==0)||(Data[(i-1)*step_mark+j]==0)||(Data[(i+1)*step_mark+j]==0);????????????????//判斷該點(diǎn)是否有相鄰好點(diǎn)
???????if((Data[i*step_mark+j]==255)&&one)?????????????????????????????????????
???{
??????????k++;
??struct?no

評(píng)論

共有 條評(píng)論