필터 지우기
필터 지우기

how to smooth / refine edges ??

조회 수: 33 (최근 30일)
waqas pervaiz
waqas pervaiz 2013년 6월 6일
답변: Pallawi Pallawi 2017년 9월 21일
hello all, i have a final image as an output.. as a result of processing image edges got irregular... how can it be possible for me to smooth/refine just the edges not the complete image... actually i was trying to apply gaussian filter on it it smooths the entire image... P.S image type is RGB .. waiting for replies...
Thanks,

채택된 답변

Sean de Wolski
Sean de Wolski 2013년 6월 6일
편집: Sean de Wolski 2013년 6월 6일
Similar to what Paul is suggesting:
%Standard IPT Image
I = imread('cameraman.tif');
%Its edges
E = edge(I,'canny');
%Dilate the edges
Ed = imdilate(E,strel('disk',2));
%Filtered image
Ifilt = imfilter(I,fspecial('gaussian'));
%Use Ed as logical index into I to and replace with Ifilt
I(Ed) = Ifilt(Ed);
For an RGB image you may first have to repmat() Ed so that it exists in all three dimensions
Ed3 = repmat(Ed,[1 1 3]);
  댓글 수: 4
waqas pervaiz
waqas pervaiz 2013년 6월 7일
Thanks alot Sean, but i am getting the following errors:
*Error using iptcheckinput Function EDGE expected its first input, I, to be two-dimensional.
Error in edge>parse_inputs (line 547) iptcheckinput(I,{'numeric','logical'},{'nonsparse','2d'},mfilename,'I',1);
Error in edge (line 190) [a,method,thresh,sigma,thinning,H,kx,ky] = parse_inputs(varargin{:});
Error in ed (line 4) E = edge(I,'canny'); *
Sean de Wolski
Sean de Wolski 2013년 6월 7일
If you change the image to be three dimensional, you'll need to either extract a color plane from it or use rgb2gray
For example
Igray = rgb2gray(I);
or
Ired_channel = I(:,:,1);

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Paul Kelly
Paul Kelly 2013년 6월 6일
I've never tried this but I would probably approach it in the following way:
convert the image to grayscale RGB = imread(imageFile); I = rgb2gray(RGB);
binarise it (this will be quite tricky) or find another way to isolate the edge you are interested in. For example:
level = graythresh(I);
BW = im2bw(I,level);
find the edges of the binarised image:
edgeImage = edge(BW,'canny');
Then use morphological functions to broaden the edges to a reasonable size
Finally use the edge image as a mask for the smoothing operation

Pallawi Pallawi
Pallawi Pallawi 2017년 9월 21일
Image 1 with the gray background was my input image and I removed the gray background with a white one! Now I need to refine the edges ,making it look smoother . I have tried ,gaussian and above suggestions but it does not works.can someone please help me!LOOKING FOR AN URGENT HELP.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by