用matlab读取lena_gray.tif 图像,然后使用prewitt 算子对图像进行锐化,同屏显示原图像和锐化后图像
时间: 2024-02-03 08:15:24 浏览: 174
好的,以下是实现的代码:
```matlab
% 读取图像
lena = imread('lena_gray.tif');
% 显示原图像
subplot(1,2,1);
imshow(lena);
title('Original Image');
% 使用Prewitt算子进行锐化
prewitt_filter = [-1,-1,-1;0,0,0;1,1,1];
lena_prewitt = imfilter(double(lena), prewitt_filter);
% 显示锐化后图像
subplot(1,2,2);
imshow(lena_prewitt, []);
title('Sharpened Image (Prewitt)');
```
运行以上代码,即可在同一画布上显示原图像和使用Prewitt算子锐化后的图像。
相关问题
用matlab读取lena_gray.tif 图像使用sobel 算子对图像进行锐化,同屏显示原图像和锐化后图像 然后使用LoG 算子对图像进行锐化,同屏显示原图像和锐化后图像
好的,下面是MATLAB代码实现:
```matlab
% 读取lena_gray.tif图像
I = imread('lena_gray.tif');
% Sobel算子锐化
sobel = fspecial('sobel');
I_sobel = imfilter(I, sobel);
I_sharp_sobel = imsubtract(I, I_sobel);
% LoG算子锐化
log = fspecial('log');
I_log = imfilter(I, log);
I_sharp_log = imsubtract(I, I_log);
% 显示原图和锐化后的图像
figure;
subplot(2,2,1);imshow(I);title('原图像');
subplot(2,2,2);imshow(I_sobel);title('Sobel算子锐化');
subplot(2,2,3);imshow(I_sharp_sobel);title('Sobel算子锐化后');
subplot(2,2,4);imshow(I_sharp_log);title('LoG算子锐化后');
```
运行以上代码,即可得到同屏显示原图像和锐化后图像的结果。
使用matlab读取 lena_color.tif 图像,显示彩色图像,提取三个图像分量,同屏显示彩色图像及其各个分量图像,同屏显示三个图像分量的直方图
好的,我知道了。以下是Matlab代码实现:
```matlab
% 读取彩色图像
img = imread('lena_color.tif');
% 显示彩色图像
figure;
imshow(img);
title('Original Image');
% 提取三个分量
R = img(:,:,1);
G = img(:,:,2);
B = img(:,:,3);
% 同屏显示彩色图像及其各个分量图像
figure;
subplot(2,2,1);
imshow(img);
title('Original Image');
subplot(2,2,2);
imshow(R);
title('Red Component');
subplot(2,2,3);
imshow(G);
title('Green Component');
subplot(2,2,4);
imshow(B);
title('Blue Component');
% 同屏显示三个图像分量的直方图
figure;
subplot(3,1,1);
imhist(R);
title('Red Component Histogram');
subplot(3,1,2);
imhist(G);
title('Green Component Histogram');
subplot(3,1,3);
imhist(B);
title('Blue Component Histogram');
```
运行后,会弹出两个窗口,第一个窗口显示原始的彩色图像,第二个窗口分成四个小区域,左上角显示原始的彩色图像,右上角、左下角、右下角分别显示红色、绿色、蓝色三个分量的图像。第三个窗口同样分成三个小区域,分别显示三个分量的直方图。
阅读全文
相关推荐












