RSS

Monthly Archives: November 2011

image data access in OpenCV 2 or later.

Scrapped from : http://tech.groups.yahoo.com/group/OpenCV/message/84478

Since 2009 with the launch of OpenCV 2, you can count with the new C++ interface, much better than the C style older version. I suggest two ways you can access pixels values. My notes are based on the book OpenCV 2 Computer Vision Application Programming Cookbook, by Robert Laganière.
1. Direct access to pixels values:
     // Test for gray level image
    if (image.channels() == 1) {
        image.at<uchar>(j, i) = …;           // j runs on rows, i runs on cols
    } else if (image.channels() == 3)   // color image
       image.at<cv::Vec3b>(j, i)[0] = …;
       image.at<cv::Vec3b>(j, i)[1] = …;
       image.at<cv::Vec3b>(j, i)[2] = …;
   }
   The image was created as: cv::Mat image = cv::imread(“img.???”);
2. Scanning image with pointer:
    uchar *pixel;
     cv::Mat image = cv::imread(“img.???”);
     . . .
    for (int j = 0; j < nRow; j++) {
          // Get the address of row j
          pixel = image.ptr<uchar>(j);
          for (int i = 0; i < nCol; i++) {
                // process each pixel
               pixel[i] = …;
               …
          }
     }
choose one method and good job!
 
1 Comment

Posted by on November 23, 2011 in OpenCV

 

Rotation iplimage by 90 degrees

Umm. Transpose then flip?  Sounds nice.

What is gpu::rotate for then?

http://stackoverflow.com/questions/2259678/easiest-way-to-transpose-an-image-rotate-by-90-degrees-using-opencv

 
Leave a comment

Posted by on November 8, 2011 in Computer Vision