【问题标题】:Need to apply edge filtering algorithm on series of images需要对一系列图像应用边缘滤波算法
【发布时间】:2023-03-08 03:30:01
【问题描述】:

我想在 matlab 中编写一个代码,它将接受来自隐式给定目录的图像,并在移动中对每个图像应用 Sobel 边缘检测算法。请帮忙

【问题讨论】:

    标签: matlab image-processing edge-detection


    【解决方案1】:

    MATLAB 中的 Sobel 边缘检测仅适用于灰度图像,因此您需要将任何图像转换为灰度表示。如果您在桌面上有一个文件夹,其中所有图像都驻留,那么下面的 sn-p 代码可以满足您的需求。

    dirname = '~/Desktop/imgs/';
    files = dir([dirname, '*.png']);
    files = {files.name}';
    for ifile = 1:numel(files)
        imfile = [dirname, files{ifile}];
        im = imread(imfile);               % Read the image file
        img = rgb2gray(im);                % Convert to grayscale
        ime = edge(img, 'sobel');          % Edge detection
    
        figure(1)
        imshow(ime);
        outname = ['edge_', files{ifile}];
        imwrite(ime, outname);
    end
    

    希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 2012-07-14
      • 2018-04-04
      • 2021-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多