Eroding and dilating an image
    조회 수: 17 (최근 30일)
  
       이전 댓글 표시
    
I need help.  This code is to dilate and erode the image.  How can I fix it? 
 
 
 댓글 수: 0
채택된 답변
  Image Analyst
      
      
 2023년 1월 4일
        
      편집: Image Analyst
      
      
 2023년 1월 4일
  
      Line 3 has two equals signs on it.  You can't do that.  And ~ doesn't work for a gray scale image. You can do
c = imread('cameraman.tif');
se = strel('disk', 5, 0);
a = imerode(c, se);
subplot(1, 2, 1);
imshow(a);
dilatedImage = imdilate(imcomplement(c), se);
subplot(1, 2, 2);
imshow(dilatedImage);
댓글 수: 0
추가 답변 (1개)
  Yusuf Suer Erdem
      
 2023년 1월 4일
        you could try these codes that I found:
% Dilating and eroding an image
    % Original image
    im = imread('circbw.tif');
    subplot(2,3,1);
    imshow(im);
    [x,y] = size(im);
    title(sprintf('Original image (%dx%d)', x,y));
    %% Dilation
    % Create a structuring element
    se = strel('square', 3);
    % Dilate the image with the structuring element
    im1 = imdilate(im, se);
    subplot(2,3,2);
    imshow(im1);
    title('Dilated image');
    %% Erosion
    % Create a structuring element
    se = strel('square', 3);
    im2 = imerode(im, se);
    subplot(2,3,3);
    imshow(im2);
    title('Eroded image');
    %% Erosion und Dilation are dual:
    se = strel('square', 3);
    im3 = 1 - imerode(1-im, se);
    subplot(2,3,5);
    imshow(im3);
    title('Eroded Background');
    im4 = 1 - imdilate(1-im, se);
    subplot(2,3,6);
    imshow(im4);
    title('Dilated Background');
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



