GPT答: |
https://ask.gongduoduo.com
|
% 读取lena图像
I = imread('lena.jpg');
% 灰度范围线性扩展
a = 0.3;
b = 0.6;
c = 0.1;
d = 0.9;
linear_expanded_I = imadjust(I, [a b], [c d]);
% 非线性扩展
gamma = 2;
nonlinear_expanded_I = imadjust(I, [], [], gamma);
% 灰度倒置
inverted_I = imcomplement(I);
% 图像二值化
level1 = 0.4;
level2=0.7;
binary_I1=imbinarize(I, level1);
binary_I2=imbinarize(I, level2);
% 显示结果图像
subplot(3,3,1),imshow(I),title('原始图像');
subplot(3,3,4),imshow(linear_expanded_I),title('灰度范围线性扩展');
subplot(3,3,5),imshow(nonlinear_expanded_I),title('非线性扩展');
subplot(3,3,[7]),imshow(inverted_I),title('灰度倒置');
subplot(3 ,8,[10]), imshow(binary_ I1) , title ('二值化(level- O .4)');
subplot (338) , imshow ( binary_ I2 ) , title ('二值化(level- O .7)' ) ;
|