Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IplImage * I = cvLoadImage( "myimage.tif" );
- CvScalar pixel = cvGet2D( I, y, x );
- cv::Mat I = cv::imread( "myimage.tif" );
- if( I.depth() == CV_8U && I.channels() == 3 )
- cv::Vec3b pixel = I.at<cv::Vec3b>( x, y );
- else if( I.depth() == CV_32F && I.channels() == 1 )
- float pixel = I.at<cv::float>( x, y );
- Mat img; // My input mat, initialized elsewhere
- // Pretty fast operation, Will only create an iplHeader pointing to the data in the mat
- // No data is copied and no memory is mallocated.
- // The Header resides on the stack (note its type is "IplImage" not "IplImage*")
- IplImage iplImg = (IplImage)img;
- // Then you may use the old (slow converting) legacy-functions if you like
- CvScalar s = cvGet2D( &iplImg, y, x );
- cv::Mat mat = ...; // something
- cv::Scalar value = cv::mean(mat(cv::Rect(x, y, 1, 1)));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement