- scale the data yourself: out = double(inp)/255
- tell imshow the range to use: imshow(inp,[0,255])
Using double instead of im2double for images?
12 次查看(过去 30 天)
显示 更早的评论
I want to convert an input image into floating point, so that interpolation using interp2 will be possible. I want to achieve this without using the Image Processing Toolbox and without the im2double function. So I tried the syntax I=double(I), however, the resulting image looked very different than the original.
Here is a comparison of the resulting images using im2double(I) and double(I) respectively:
What is happening here? It looks like the double(I) code eliminates the higher frequencies from the spectrum of the image:
When I plot double(I) using imagesc instead of imshow I get the right image displayed, but the spectrum is still shrunken.
So, how can I implement what im2double does without using the pre-defined function? Any explanation is greatly appreciated.
0 个评论
采纳的回答
Stephen23
2017-4-1
编辑:Stephen23
2017-4-1
"What is happening here?"
You input image is of class uint8, which means its values are from [0-255]. When you call double, you get the same range of values [0-255]. In contrast calling im2double scales the output to [0-1] (have a look in the variable viewer, and you will see that their output values are different).
imshow by default assumes that its inputs are [0-1]. So when you give it data [0-255] all of the values above 1 are shown as white. There are two easy solutions:
0 个评论
更多回答(1 个)
Mohammad Anas
2017-4-1
From your question, I can guess the solution to your problem is very simple. You probably may have to scale back the resulting image by multiplying with a factor of 255 in order to see the same image that would result by using im2double. Hope that helps.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!