79 lines
1.7 KiB
Matlab
79 lines
1.7 KiB
Matlab
% 读取图片
|
|
image = imread('EXP_1_2/test.jpg');
|
|
|
|
% 灰度化处理
|
|
image_gray = rgb2gray(image);
|
|
|
|
% RGB色彩分离
|
|
red = image(:, :, 1);
|
|
green = image(:, :, 2);
|
|
blue= image(:, :, 3);
|
|
|
|
image_red = cat(3, red, zeros(size(red), 'uint8'), zeros(size(red), 'uint8'));
|
|
image_green = cat(3, zeros(size(green), 'uint8'), green, zeros(size(green), 'uint8'));
|
|
image_blue = cat(3, zeros(size(blue), 'uint8'), zeros(size(blue), 'uint8'),blue);
|
|
|
|
% 均衡化处理
|
|
red_eq = histeq(red);
|
|
green_eq = histeq(green);
|
|
blue_eq = histeq(blue);
|
|
|
|
image_eq = cat(3, red_eq, green_eq, blue_eq);
|
|
|
|
% 展示照片
|
|
figure;
|
|
subplot(2,2,1);
|
|
imshow(image);
|
|
title('Original Image'); %原图
|
|
subplot(2,2,2);
|
|
imshow(image_red);
|
|
title('Red Channel'); %红色通道
|
|
subplot(2,2,3);
|
|
imshow(image_green);
|
|
title('Green Channel'); %绿色通道
|
|
subplot(2,2,4);
|
|
imshow(image_blue);
|
|
title('Blue Channel'); %蓝色通道
|
|
|
|
figure;
|
|
ax1 = subplot(2,2,1);
|
|
imshow(image_gray);
|
|
colormap(ax1, gray);
|
|
title('Original Image'); %原图
|
|
ax2 = subplot(2,2,2);
|
|
imagesc(image_gray);
|
|
colormap(ax2, hsv);
|
|
colorbar;
|
|
title('Hsv'); %Hsv
|
|
ax3 = subplot(2,2,3);
|
|
imagesc(image_gray);
|
|
colormap(ax3, autumn);
|
|
colorbar;
|
|
title('Autumn'); %Autumn
|
|
ax4 = subplot(2,2,4);
|
|
imagesc(image_gray);
|
|
colormap(ax4, copper);
|
|
colorbar;
|
|
title('Copper'); %Copper
|
|
|
|
figure;
|
|
subplot(1,2,1);
|
|
imshow(image);
|
|
title('Original Image'); %原图
|
|
subplot(1,2,2);
|
|
imhist(image);
|
|
title('Histogram'); %直方图
|
|
|
|
figure;
|
|
subplot(2,2,1);
|
|
imshow(image);
|
|
title('Original Image'); %原图
|
|
subplot(2,2,2);
|
|
imshow(image_eq);
|
|
title('Equalization'); %均衡化
|
|
subplot(2,2,3);
|
|
imhist(image);
|
|
title('Original Histogram'); %原图直方图
|
|
subplot(2,2,4);
|
|
imhist(image_eq);
|
|
title('Equalization Histogram'); %均衡化直方图 |