作用:
对进行图像的灰度变换,即调节灰度图像的亮度或彩色图像的颜色矩阵。
格式:
- g = imadjust(f,[low_in; high_in],[low_out; high_out])
将图像I中的亮度值映射到J中的新值。即将low_in至high_in之间的值映射到low_out至high_out之间的值。
low_in 以下与 high_in 以上的值被剪切掉了,即低于low_in的作为low_in进行映射,高于high_in的作为high_in 进行映射。
[low_in; high_in]和[low_out; high_out]都可以使用空矩阵表示,默认为[0,1]
除f外,其他参数都在0到1之间。如果high_out<low_out,则输出灰度将被反转。
f = imread('C:\Users\win\Desktop\city-street.jpg'); %调整灰度图像的灰度范围
g = imadjust(f,[0.2;0.6],[0;1]);
figure(1);
subplot(1,2,1);imshow(f);title('原图');
subplot(1,2,2);imshow(g);title('调节灰度的图')
原图像的灰度范围在0~255之间,imadjust将小于0.2x255的值设为0,将大于0.6x255的值设为255。
- stretchlim()
计算灰度图像的最佳输入区间。
使用stretchlim()和imadjust()共同对调整灰度图像的灰度范围
f = imread('C:\Users\win\Desktop\landscape.jpg');
s = stretchlim(f);%计算灰度图像的最佳输入区间
g = imadjust(f,s,[0,1]);%调整灰度图像的灰度范围
figure(1);
subplot(1,2,1);imshow(f);title('原图');
subplot(1,2,2);imshow(g);title('调节灰度的图')
- g = imadjust(f,[low_in; high_in],[low_out; high_out],gamma)
将图像 I 中的亮度值映射到 J 中的新值。其中 gamma指定描述值f和值g关系的曲线形状。
如果gamma小于1,此映射偏重更高数值(明亮)输出;
如果gamma大于1,此映射偏重更低数值(灰暗)输出;
默认gamma为1(线性映射)。
f = imread('C:\Users\win\Desktop\landscape.jpg');
s = stretchlim(f);%计算灰度图像的最佳输入区间
g = imadjust(f,s,[0,1],0.6);%调整灰度图像的灰度范围
h = imadjust(f,s,[0,1],6);
figure(1);
subplot(1,3,1);imshow(f);title('原图');
subplot(1,3,2);imshow(g);title('gamma = 0.6')
subplot(1,3,3);imshow(h);title('gamma = 6');
- RGB2 = imadjust(RGB1,…)
对 RGB 图像 RGB1 的红、绿、蓝调色板分别进行调整。随着颜色矩阵的调整,每一个调色板都有唯一的映射值。
f = imread('C:\Users\win\Desktop\rabbit.jpg');
g = imadjust(f,[0.2 0.3 0.1;0.6 0.8 0.9],[],0.6);%imadjust对RGB图像进行处理
figure(1);
subplot(1,2,1);imshow(f);title('原图');
subplot(1,2,2);imshow(g);title('处理后的图像')