Matlab imshow没有正确绘制,但imshowpair确实如此 [英] Matlab imshow doesn't plot correctly but imshowpair does
问题描述
我导入了一张图片。我已将其解析为双精度并对其执行了一些过滤。
I have imported an image. I have parsed it to double precision and performed some filtering on it.
当我用 imshow
绘制结果时,双重图像太暗。但是,当我使用 imshowpair
绘制原始图像和最终图像时,两个图像都会正确显示。
When I plot the result with imshow
, the double image is too dark. But when I use imshowpair
to plot the original and the final image, both images are correctly displayed.
我有试图使用 uint8
, im2uint8
,乘以255然后使用这些函数,但唯一的方法是获得正确的图片正在使用 imshowpair
。
I have tried to use uint8
, im2uint8
, multiply by 255 and then use those functions, but the only way to obtain the correct image is using imshowpair
.
我该怎么办?
推荐答案
这听起来像是一个问题,你的大部分强度/颜色数据超出了 imshow
当显示 double
数据时。
It sounds like a problem where the majority of your intensities / colour data are outside the dynamic range of what is accepted for imshow
when showing double
data.
我也看到你正在使用 im2double
,但是 im2double
只是将图像转换为double,如果图像已经加倍,则没有任何反应。这可能是因为您过滤图像的方式。你在做某种边缘检测吗?你得到黑暗图像的原因可能是因为你的大部分强度都是负数,或者是在0左右徘徊。 imshow
显示 double
类型图像假设强度的动态范围是[0,1]。
I also see that you're using im2double
, but im2double
simply converts the image to double and if the image is already double, nothing happens. It's probably because of the way you are filtering the images. Are you doing some sort of edge detection? The reason why you're getting dark images is probably because the majority of your intensities are negative, or are hovering around 0. imshow
whe displaying double
type images assumes that the dynamic range of intensities is [0,1].
因此,解决问题的一种方法是:
Therefore, one way to resolve your problem is to do:
imshow(im,[]);
这会移动显示范围,使得最小值映射为0,最大值为1 。
This shifts the display so that range so the smallest value is mapped to 0, and the largest to 1.
如果您想要一个更永久的解决方案,请考虑创建一个新的输出变量,为您完成此任务:
If you'd like a more permanent solution, consider creating a new output variable that does this for you:
out = (im - min(im(:))) / (max(im(:)) - min(im(:)));
这将执行与 imshow
相同的转移为您显示数据时。您现在可以这样做:
This will perform the same shifting that imshow
does when displaying data for you. You can now just do:
imshow(out);
这篇关于Matlab imshow没有正确绘制,但imshowpair确实如此的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!