GPT答: |
7i24.cn
|
```matlab
% 读取灰度图像lena
I = imread('lena.jpg');
I = rgb2gray(I);
% 灰度级变换函数,线性扩展
a = 0.3;
b = 0.6;
c = 0.1;
d = 0.9;
J_linear = imadjust(I, [a b], [c d]);
% 非线性扩展函数参数设置为c-2
gamma_value = 2;
J_nonlinear = imadjust(I, [], [], gamma_value);
% 灰度倒置变换函数s=255-s进行图像变换
J_inverted = imcomplement(I);
% 设置二值化图像的阈值level=0.4和level=0.7
level1 = 0.4;
BW1_thresholded_image_1D_array_representation_of_the_binary_image_which_is_returned_by_imbinarize_function_J_binary_1D_array_representation_of_the_binary_image_returned_by_imbinarize_function_J_binary_1D_array_representation_of_the_binary_image_returned_by_imbinarize_function_J_binarized_level_07thresholding_thresholding_thresholding_thresholding_level07thresholding_level07thresholding_level07thresholdinglevel07 J_binarized_level04 J_binarized level04 thresholdinglevel04 thresholdinglevel04 thresholdinglevel04
figure; subplot(2,3,1); imshow(I); title('Original Image');
subplot(2,3,2); imshow(J_linear); title('Linearly Enhanced Image');
subplot(2,3,3); imshow(J_nonlinear); title('Non-linearly Enhanced Image');
subplot(2,3,4); imshow(J_inverted ); title('Inverted Image');
```
|