Using OPENCV for Digital image processing jobs-using notes

Source: Internet
Author: User

The input images of digital image processing jobs are all grayscale images, so summarize the answers to the questions you encounter.

    1. The OCV image container is mat<typename>, and the image can be read with imread (filename), and filename is both C string,char* and const char*. The typename of the grayscale image is the typename of the Uchar,rgb image is vec3b.
    2. Mat container If you use the operator to assign a value, only copy a copy of the information header without copying the matrix containing the data, thereby reducing the memory waste and speed, so the resulting multiple Mat objects point to the same data matrix, in other words, if an object to the matrix operation, Then other objects that also point to the matrix will find their matrix changed.
    3. Traversing pixels can use mat::at<typename> (i, J), for grayscale images, Typename=uchar,on-the-fly way, Slowest Oh _ (: З"∠) _;Uchar pointer traversal (It is best to Judge iscontinuous () so that the two-dimensional matrix can be changed to one-dimensional arrays); iterative method , which is the safest, no pointer out of bounds, and for grayscale images, whether or not continuous, Can be traversed with begin and end as a one-dimensional array, and finally the core function Lut, the fastest, but not very well-understood. Please click here for several methods
    4. The way to verify that the image was read successfully is to use the mat::d ata, this value will be null if it is not successfully read, otherwise the pointer to the first column of the first row of the image matrix is returned.

Attach the official tutorial recommended efficient traversal method Uchar pointer code

1mat& scanimageandreducec (mat& I,Constuchar*Consttable)2 {3     //accept only char type matrices4Cv_assert (i.depth ()! =sizeof(Uchar)); 5 6     intChannels =i.channels ();7 8     intNRows = I.rows *channels;9     intNCols =I.cols;Ten  One     if(I.iscontinuous ()) A     { -NCols *=nRows; -NRows =1;  the     } -  -     inti,j; -uchar*p; +      for(i =0; i < nRows; ++i) -     { +p = i.ptr<uchar>(i); A          for(j =0; J < NCols; ++j) at         { -P[J] =Table[p[j]];  -         } -     } -     returnI; -}

Below put a few feel to learn OCV Foundation very good blog, in fact, the above points are from these, thank them for sharing!

http://blog.csdn.net/xiaowei_cqu/article/details/7771760

Http://www.cnblogs.com/ronny/p/opencv_road_2.html

Using OPENCV for Digital image processing jobs-using notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.