Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to get 16bit unsigned int values?

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,3);
    qDebug() << pixVal.val[0];
}

But I get as output this number:

-1594187515

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

How to get 16bit unsigned int values?

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,3);
im.at<cv::Vec3i>(0,2);
    qDebug() << pixVal.val[0];
}

But I get as output this number:

-1594187515
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