matlab图像调整

来源:互联网 发布:海淘用哪个软件 编辑:程序博客网 时间:2024/04/26 05:54

图像调整技术用于图像的改善,包括提高信噪比、通过修正图像的颜色和灰度使其某些特征更容易识别等。
1.图像灰度调整
可以直接用imadjust函数直接调整灰度的范围而调整灰度

I = imread('pout.tif');J=imadjust(I);subplot(221);imshow(I)subplot(223);imhist(I,64)subplot(222);imshow(J)subplot(224);imhist(J,64)

这里写图片描述
还可以通过调节灰度范围内的灰度子范围数据,来实现增大或者是减小图像对比度的效果。
比如,下面我们将灰度范围是【0,51】的值,调整到灰度范围是【128,255】的值,并且将灰度范围是【128,255】的值映射为255。相应的命令如下,

I=imread('cameraman.tif');J=imadjust(I,[0 0.2],[0.5 1]);subplot(221);imshow(I)subplot(223);imhist(I,64)subplot(222);imshow(J)subplot(224);imhist(J,64)

这里写图片描述
利用imadjust函数还可以实现图像灰度校正,如有需要,可以参考matlab帮助文件。

2.使用直方图调整灰度
histeq函数通过直方图均衡增强对比度,简单的过程是,首先进行直方图均衡,然后通过直方图均衡转换灰度图像的亮度值或者是索引图像的颜色图值来增强对比度,输出图像的直方图近似于给定的直方图。
下面是对图像pout.tif进行直方图均衡化的程序,

I=imread('pout.tif');[J,T]=histeq(I);subplot(221);imshow(I)subplot(222);imshow(J)subplot(223);plot((0:255)/255,T)subplot(224);imhist(J,64)

这里写图片描述

3.图像色彩增强
使用decorrstretch函数可以进行彩色图像增强处理
例如,下面的命令用decorrstretch函数增强图像的色彩

A=multibandread('littlecoriver.lan',[512,512,7],'uint8=>uint8',128,'bil','ieee-le',{'band','Direct',[3 2 1]});B=decorrstretch(A);subplot(221);imshow(A)subplot(222);imshow(B)rA=A(:,:,1);gA=A(:,:,2);bA=A(:,:,3);subplot(223);plot3(rA(:),gA(:),bA(:),'.');grid onxlabel('Red (band 3)');ylabel('Green (band 2)');zlabel('Blue (band 1)');rB=B(:,:,1);gB=B(:,:,2);bB=B(:,:,3);subplot(224);plot3(rB(:),gB(:),bB(:),'.');grid onxlabel=('Red (band 3)');ylabel=('Green (band 2)');zlabel=('Blue (band 1)');

这里写图片描述
其中,左上图为原始图像,右上图是调整后的图像,左下是原始图像的色彩值分布图,右下是色彩调整后的色彩值分布图。从图中可以看出,调整过后,图像色彩明显增强。

0 0