How to access image Data from a RGB image (3channel image) in opencv

前端 未结 5 721
予麋鹿
予麋鹿 2021-01-21 14:55

I am trying to take the imageData of image in this where w= width of image and h = height of image

for (int i = x; i < x+h; i++) //height of frame pixels
{
          


        
5条回答
  •  执念已碎
    2021-01-21 15:32

    uchar* colorImgPtr;
    for(int i=0; iwidth; i++){
    
        for(int j=0; jheight; j++){
    
            colorImgPtr = (uchar *)(colorImg->imageData) + (j*colorImg->widthStep + i-colorImg->nChannels)
    
            for(int channel = 0; channel < colorImg->nChannels; channel++){
    
                //colorImgPtr[channel] here you have each value for each pixel for each channel
            }
        }
    }
    

提交回复
热议问题