Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Accessing pixel image c++

cv::Mat depth_clean(cv_depthptr->image.rows, cv_depthptr->image.cols, CV_32FC1);
cv::Mat img(cv_depthptr->image.rows, cv_depthptr->image.cols, CV_8UC1);
for(int i = 0; i < cv_depthptr->image.rows; i++)
{
    float* Di = cv_depthptr->image.ptr<float>(i);
    float* Ii = depth_clean.ptr<float>(i);
    char* Ivi = img.ptr<char>(i);
        for(int j = 0; j < cv_depthptr->image.cols; j++)
        {   
           if(Di[j] > 0.0f){                        
            Ii[j] = Di[j];
            Ivi[j] = (char) (255*((Di[j])/(5.5))); // some suitable values..
           }
            else{
            Ii[j] = 0.0f;
            Ivi[j] = 0;
            }
        }   
}

Can anyone explain to me using that program how the accessing to the pixel has been done ? using pointer and the two loops and what's the rule: if you have any course or somthing like that?

Thank you so much