Re: [問題] 關於OpenCV
: 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
推
03/15 11:00, , 1F
03/15 11:00, 1F
→
03/15 20:40, , 2F
03/15 20:40, 2F
討論串 (同標題文章)
Programming 近期熱門文章
PTT數位生活區 即時熱門文章