4/22/2014

(OpenCV Study) Mat point access method, get pixel

1. At approach

Mat image (ROW, COL, CV_TYPE);
image.at (WANT_ROW, WANT_COL);

- ROW: Row
- COL: Column
- CV_TYPE: data type ( for example : CV_8UC3 = 8 bit 3 channels)
- DATA_TYPE: Mat creation data type ( for example : float, usigned char)
- WANT_ROW: access to the desired row
- WANT_COL: access to the desired column

[Advantage]: Access after validation progress , so safe and accurate approach .
[Disadvantage]:  most slow in 3 ways.

2. Ptr approach
Mat image (ROW, COL, CV_TYPE);
image.ptr (WANT_ROW, WANT_COL); (This access is changed to the Point)

- ROW: Row
- COL: Column- CV_TYPE: data type ( for example : CV_8UC3 = 8 bit 3 channels)
- DATA_TYPE: Mat creation data type ( for example : float, usigned char)
- WANT_ROW: access to the desired row
- WANT_COL: access to the desired column

[Advantage]: Access is faster than first way.
[Disadvantage]: direct access to the data , but way slower than third way .



3. Data approach
Mat image (ROW, COL, CV_TYPE);
DATA_TYPE * data = (DATA_TYPE *) image.data;data [WANT_ROW * image.cols + WANT_COL]

- ROW: Row
- COL: Column
- CV_TYPE: data type ( for example : CV_8UC3 = 8 bit 3 channels)
- DATA_TYPE: Mat creation data type ( for example : float, usigned char)
- WANT_ROW: access to the desired row
- WANT_COL: access to the desired column

[Advantage]: very fast.
[Disadvantage]: not check validation ,  it is hard to know inadequate access.


This is sample code.
http://study.marearts.com/2016/06/opencv-pixel-access-at-ptr-data.html

1 comment:


  1. Hi every body on this site,my name is FIDELIA WAYNE, I want to give a testimony about my HERPES that was cured by a herbal doctor .few months years back i noticed some changes and symptoms in my body. which made me spend alot of money but couldn't get a cure, I never thought that I live again and I am very grateful to this great man named dr OLOKUN toward my HERPES situations, who cured me last 4 weeks. I was in great pain so I told one of my best friend; she told me it's not a big that there is a spell caster that can cure my HERPES.a test and I did, when the doctor told me that I should go for a test i did it doubting,to my greatest surprise it wasnt found in my body system anymore I could not believe myself, I went to see another doctor the result was still the same, I was human on the planet earth again, so I emailed and thanked him. Please, if you are having a similar problem please contact him through his email drolokuntemple@gmail.com OR whatsapp hem on this very numberor +2348132537313

    ReplyDelete