MATLAB实战系列(一)-二维路径规划算法续集-图像边缘提取(附代码)

tech2026-01-14  13

用MATLAB实现的图像边缘提取的代码: 

clear;clc; I=imread('lena.bmp'); I=rgb2gray(I); imshow(I,[]); title('Original Image'); sobelBW=edge(I,'sobel'); figure; imshow(sobelBW); title('Sobel Edge'); robertsBW=edge(I,'roberts'); figure; imshow(robertsBW); title('Roberts Edge'); prewittBW=edge(I,'prewitt'); figure; imshow(prewittBW); title('Prewitt Edge'); logBW=edge(I,'log'); figure; imshow(logBW); title('Laplasian of Gaussian Edge'); cannyBW=edge(I,'canny'); figure; imshow(cannyBW); title('Canny Edge');

 

3-6行代码的含义为导入图片,接下来用5种算子对图像边缘进行提取。以文中的封面图片为例演示5种算子的图像边缘提取效果。

原始图像

最新回复(0)