用widthStep的方法來增加某範圍的像素----與imageROI對比

來源:互聯網
上載者:User

標籤:

//用widthStep的方法來增加某範圍的像素//sandy//時間:2015-10-5#include <cv.h>#include <highgui.h>int main(int argc, char** argv){    //載入圖片    IplImage* interest_img;    interest_img=cvLoadImage("E:\\picture\\d.jpg",1);    //定義一個矩形作為感興趣地區    CvRect rect=cvRect(100,150,250,250);    //建立IplImage映像頭,制定映像的尺寸,深度和通道數    IplImage *sub_img= cvCreateImageHeader(                                            cvSize(rect.width,rect.height ),//映像的尺度=矩形尺度                                            interest_img->depth ,                                            interest_img->nChannels                                             );        sub_img->origin =interest_img->origin ;//定義映像座標原點的位置    sub_img->widthStep =interest_img->widthStep;    //imageData指標指向興趣子領域    sub_img->imageData =interest_img->imageData +                rect.y *interest_img->widthStep +                rect.x *interest_img->nChannels ;    //藍色通道增加100    cvAddS(sub_img,cvScalar(100),sub_img);//【存放單通道映像中像素:cvScalar(255)】把第一個sub_img的元素與cvScalar(100)相加放到第二個sub_img裡。    //顯示    cvNamedWindow("roi_add",1);    cvShowImage("roi_add",sub_img);    //釋放    cvReleaseImageHeader(&sub_img);    cvWaitKey();        return 0;}

用widthStep的方法來增加某範圍的像素----與imageROI對比

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.