Ask Your Question
0

How to get 16bit unsigned int values?

asked 2018-01-04 05:02:12 -0600

pauledd gravatar image

updated 2018-01-04 05:06:51 -0600

Hi

I am very new in programming so pls bear with me!
I have an 16bit unsigned integer RGB PNG with 4x2 Pixels.
ImageMagick interprets the image like this:

# ImageMagick pixel enumeration: 4,2,65535,srgb
0,0: (0,0,0)  #000000000000  black
1,0: (19941,19941,19941)  #4DE54DE54DE5  srgb(30%,30%,30%)
2,0: (41210,41210,41221)  #A0FAA0FAA105  srgb(63%,63%,63%)
3,0: (65535,65535,65535)  #FFFFFFFFFFFF  white
0,1: (0,0,0)  #000000000000  black
1,1: (19941,19941,19941)  #4DE54DE54DE5  srgb(30%,30%,30%)
2,1: (41210,41210,41221)  #A0FAA0FAA105  srgb(63%,63%,63%)
3,1: (65535,65535,65535)  #FFFFFFFFFFFF  white

How can I get, for example the blue pixel value for the 3rd pixel in in the first row, as unsigned int (0-65535) from OpenCV? My first approach would be (using qDebug() to output):

im = cv::imread(filename,cv::IMREAD_UNCHANGED);
if(!im.empty)
{
    cv::Vec3i pixVal = im.at<cv::Vec3i>(0,2);
    qDebug() << pixVal.val[0];
}

But I get as output this number:

0

I would like to get 41221. Is there an unsigned int type in OpenCV? Any ideas anyone?

Attachement: The 4x2 Png
C:\fakepath\4x2.png

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-01-04 05:27:30 -0600

berak gravatar image

the correct way to access CV_16U3C pixels is:

 cv::Vec3w pixVal = im.at<cv::Vec3w>(0,2); // unsigned short

for CV_16S3C it would be:

 cv::Vec3s pixVal = im.at<cv::Vec3s>(0,2); // signed short
edit flag offensive delete link more

Comments

Does w stand for wide?

sjhalayka gravatar imagesjhalayka ( 2018-01-05 15:59:43 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-01-04 05:02:12 -0600

Seen: 1,078 times

Last updated: Jan 04 '18