简体   繁体   中英

imshow img with values 0 1 with opencv

I have a mat of this type

Mat port(M.size(),CV_8UC1);

and inside I have the 2 values: ​​0 and 1.

If I try to do imshow ( " p " , port) ;
img by a black .

How can I distinguish all 0 and 1 with two different colors ?

I tried and tried to use line() but you must already know the two closest points while I do not know what the values ​​1 distanced from each other . someone can help me ? It seems a trivial problem

Try scaling your data for display: imshow(" p ", port*255);

A gray value of 1 is almost indistinguishable from full black and will not be discernible on any normal monitor/screen. Scaling by 255 will make these pixels appear white.
Note that the scaling is done only for the display and do not affect the image itself.

Please see the imshow() docs for what scaling is done and the values for display:

The function may scale the image, depending on its depth:

  • If the image is 8-bit unsigned, it is displayed as is.
  • If the image is 16-bit unsigned or 32-bit integer, the pixels are divided by 256. That is, the value range [0,255*256] is mapped to [0,255].
  • If the image is 32-bit floating-point, the pixel values are multiplied by 255. That is, the value range [0,1] is mapped to [0,255].

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM