1

I have an image of data type logical. When I convert it to uint8 I get a blank image. I'm trying to compare this image with another image, and they have to be of the same data type.

If that doesn't work, are there data types I can convert to without getting a blank result.

I have two images, one with the type logical and the other with type uint8. If the above doesn't work, what same data type can I convert to in order to be able to compare them together?

Charles
  • 50,943
  • 13
  • 104
  • 142
Simplicity
  • 47,404
  • 98
  • 256
  • 385

2 Answers2

0

The conversion worked just fine. When you display a uint8 image, the brightest value is 255, but in your image, the intensities only go up to 1. If you look at the matrix, it is not blank. You can display the image in double format to see that there the mask is still there, or multiply your converted image by 255 (or whatever).

chappjc
  • 30,359
  • 6
  • 75
  • 132
0

Example:

bw = rand(5)<0.5;    % some logical image mask

iptsetpref('ImshowInitialMagnification','fit')

% display logical image
imshow(bw)

% convert to UINT8 and multiply by 255
imshow(uint8(bw)*255)

% convert to UINT8 and specify appropriate display range
% (empty will compute it from data: [min max] == [0 1])
imshow(uint8(bw), [])
Amro
  • 123,847
  • 25
  • 243
  • 454