Does imtool work on an image of type double?

1 次查看(过去 30 天)
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.

回答(1 个)

DGM
DGM 2021-8-27
编辑:DGM 2021-8-27
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 个评论
sparsh garg
sparsh garg 2021-8-27
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 2021-8-27
编辑:DGM 2021-8-27
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().

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by