Clear Filters
Clear Filters

Does imtool work on an image of type double?

2 views (last 30 days)
sparsh garg
sparsh garg on 27 Aug 2021
Edited: DGM on 27 Aug 2021
So I have an image and I have converted it to double so that I can do some mathematical operations on it like taking the log of pixels etc
My question is after I compute the log,the result is a double matrix,
now I can view this as imshow(I,[]) but if I was to send that output to say imtool the result doesn't show
Similarly when I send the same output to other functions like edge detection(subpixel) the result is NULL
Any help will be appreciated.

Answers (1)

DGM
DGM on 27 Aug 2021
Edited: DGM on 27 Aug 2021
How did you convert the image to double? If you did something like
A = imread('mypicture.jpg');
A = double(A);
then the image will be just be cast without being normalized. You'd want to use im2double() which does both.
Otherwise, if you did some operations on the image which pushed all the values outside the range [0 1], then you'll have to normalize it.
The image processing tools expect images to be scaled appropriately according to their class. For uint8, that'd be [0 255]. For floating point classes, it's [0 1]. If you have a [0 255] image cast as double and try to view it with imshow(), almost all the pixels will be rendered as white. When you use
imshow(A,[])
it handles the data ranging internally.
Long story short, yes it handles double images. Just make sure your images are scaled according to their class (normalized in this case).
  2 Comments
sparsh garg
sparsh garg on 27 Aug 2021
actually im2double was my first choice,but my lead told me not to use the method,and do no normalization as that is bad.So I am stuck
DGM
DGM on 27 Aug 2021
Edited: DGM on 27 Aug 2021
Any particular reason why? If you have (e.g. 0-255) scaled data in floating point, you could re-cast it back to uint8 so that imtool(), imshow(), imwrite() can handle it. ... but if you need to convert back to floating point afterwards (and back to integer for writing), then I can't imagine that such a horrible workflow is less destructive than normalization.
Depending on what you need from imtool(), you may just be able to use impixelinfo() or imcrop().

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!