imshow

imshow

Description

  • imshow(I) displays image I in a Handle Graphics® figure, where I is a grayscale, RGB (truecolor), or binary image.

    For binary images, imshow displays pixels with the value 0 (zero) as black and 1 as white.

    imshow optimizes figure, axes, and image object properties for image display.

 

  • imshow(I,[low high]) displays the grayscale image I, where [low high] is a two-element vector that specifies the display range for I.

    The value low (and any value less than low) displays as black and the value high (and any value greater than high) displays as white.     

    imshow displays values in between as intermediate(中间的) shades of gray.

 

  • imshow(I,[]) displays the grayscale image I, where [] is an empty matrix that specifies that you want imshow to scale the image based on the range of pixel values in I, using [min(I(:)) max(I(:))] as the display range.

 

  • imshow(X,map) displays the indexed image X with the colormap mapA colormap matrix can have any number of rows, but it must have exactly 3 columnsEach row is interpreted as a color, with the first element specifying the intensity of red light, the second green, and the third blue. Color intensity can be specified on the interval 0.0 to 1.0.

 

  • imshow(filename) displays the image stored in the graphics file specified by filename.
  • imshow(___,Name,Value) displays an image, using name-value pairs to control aspects of the operation.
  • himage = imshow(___) returns the handle to the image object created by imshow.

   

   (本博客系原创,转载请注明出处:http://blog.csdn.net/xuexiyanjiusheng/article/details/46956635)

   (博主cnblogs中对应文章:http://www.cnblogs.com/pfli1995/p/4658677.html)

 

注意:

  • 为了节省存储空间,matlab为图像提供了特殊的数据类型uint8(8位无符号整数),以此方式存储的图像称作8位图像。

    因此,matlab读入图像的数据是uint8,而matlab中数值一般采用double型(64位)存储和运算。所以要先将图像转为double格式 的才能运算。

  • 注意,imshow并不是只能显示灰度图像,如果unit8型或者double型数据是三维的,那么就会输出彩色图像。
  • double型的取值为0~1之间,unit8取值0~255。如果是double类型,并且范围不是0~1,那么超过1的都被看作1,会显示为白色。
  • 设 I 是一个uint8型的图像,如果直接 double(I) 再 imshow(double(I)) 的话,会输出错误的图像,有很多地方为白色,这个时候,需要先把转换为double后的图像的像素值先归一化到0~1区间,即 imshow(double(I)./255);第二种方法是,直接用 im2double ,会自动归一化到0~1,此时 imshow(im2double(I)) 即得到正确输出。 注意, im2double(I) 和 double(I)./255 是完全等价的,可以用它们分别作用后的矩阵相减,发现全为0。
  • 如果想把数据从 double 型还回到 uint8 型,也有两种方法。 一是:im2uint8(I) ; 另一种是:uint8(round(I*255)) 。注意,博主也验证过了,这两种方法也是完全等效的
  • 另外还发现了一个函数:mat2gray, 它能够将范围在 0~255 的 uint8 或者 double 型的矩阵/图像数据转化为 0~1 的 double 型矩阵/图像数据

 

读取索引图像:

  Display Indexed Image
  Read a sample indexed image, corn.tif, into the workspace, and then display it.

[X,map] = imread('corn.tif');
imshow(X,map)


  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值