GPT答: |
7i24.cn
|
```matlab
% 读取灰度图像lena
I = imread('lena.jpg');
I = rgb2gray(I);
% 灰度级变换函数s=T(r)实现图像的灰度范围线性扩展和非线性扩展
a = 0.3;
b = 0.6;
c = 0.1;
d = 0.9;
linear_expanded_image = imadjust(I,[a b],[c d]);
nonlinear_expanded_image = imadjust(I,[],[],2);
% 图像的灰度倒置变换函数s=255-r进行图像变换
inverted_image = imcomplement(I);
% 设置二值化图像的阈值,分别为level=0.4,level=0.7
threshold_level_1 = 0.4;
binary_image_1 = imbinarize(I, threshold_level_1);
threshold_level_2= 0.7;
binary_image_2=imbinarize(I, threshold_level_2);
```
|