看板 Programming 關於我們 聯絡資訊
: void GraylevelImage(IplImage* Image) : { : int i,j,r,g,b,h,w,gray; : h=Image->height; : w=Image->width; : for(i=0;i<h;i++) : { : for(j=0;j<w;j++) : { : r=((uchar*)(Image->imageData + Image->widthStep * i))[j*3+2]; : g=((uchar*)(Image->imageData + Image->widthStep * i))[j*3+1]; : b=((uchar*)(Image->imageData + Image->widthStep * i))[j*3+0]; 我都是這樣寫的     r=((uchar)(Image->imageData [Image->widthStep * i+j*3+2];    g=((uchar)(Image->imageData [Image->widthStep * i+j*3+1];     b=((uchar)(Image->imageData [Image->widthStep * i+j*3+0]; Image->widthStep 是指跳到下一行的距離           彩圖的話 通常是 width*3 : gray=(r*76+g*150+b*29)>>8; : ((uchar*)(Image->imageData + Image->widthStep * i))[j*3+2]=gray; : ((uchar*)(Image->imageData + Image->widthStep * i))[j*3+1]=gray; : ((uchar*)(Image->imageData + Image->widthStep * i))[j*3+0]=gray; : } : } : return; : } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.231.156
freestylelin:多謝!!可是為什麼我編譯不過 220.139.74.227 03/15 11:00
tocute:錯誤訊息事 ??140.112.231.156 03/15 20:40