开发者

matlab rgb values dilemma

When i wrote these commands

out = ones(size(ben))
imshow(out)

the output is a white picture but i expect almost dark picture because the rgb values are 1,1,1. when i give 255,255,255 it a开发者_高级运维lso gives a white picture. Isn't this a dilemma ?


Try out = ones(size(ben), 'uint8');

ones() by default creates an array of doubles. When imshow() gets an array of doubles it assumes that the pixel values range between 0 and 1, and assigns the white color to anything greater than 1. However, if you pass an array of uint8 to imshow() it will assume the range to be between 0 and 255.

You can also try using imagesc(); instead of imshow(), but you may need to do colormap gray after wards to get a grayscale image.

Another alternative is to rescale the image before display:

imshow(out / max(out(:)));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜