필터 지우기
필터 지우기

how to do the distance transform

조회 수: 1 (최근 30일)
Yu Zhang
Yu Zhang 2011년 12월 12일
Hi,all.I am processing a image. I need to do the distance transformation.This is my code:
myImage=imread('EarImage_1.tif');
I = rgb2gray(myImage);
whitePart = I > 220;
blackPart = I < 110;
imshow(whitePart);
I2=1-blackPart;
figure,imshow(I2);
D=bwdist(I2);
figure,imshow(~D);
This is my original picture:
After this process,I got an image just the same as "I2",which is the binary image before. I didn't get the picture as expected. I am a beginner of matlab. If anyone could tell me the solution of that, I would appreciate very much.
Thank you.
  댓글 수: 1
Walter Roberson
Walter Roberson 2011년 12월 12일
http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers

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

채택된 답변

Sean de Wolski
Sean de Wolski 2011년 12월 12일
showing ~D means that only distances equal to zero (i.e. points that are true in I2) will be shown. D is an array of doubles.
imshow(D,[]);
will show you the distance xform image with the full range of values. Good job getting to where you are, +1.
  댓글 수: 2
Yu Zhang
Yu Zhang 2011년 12월 13일
Thank you very much! I got it. But the results look not good. I could not identify the kernel at all. Could you tell me whether I should do some other processes before the distance transform? I have done the median filter and get the gradient of the image. The gradient image looks good which is clear enough.Thank you!
Sean de Wolski
Sean de Wolski 2011년 12월 13일
We need to see your image. Post it somewhere, perhaps to one of the websites in Walter's comment link and paste the url into your original question.

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 12월 12일
Do not subtract blackPart from 1 if you want to see white pixels for the locations selected by blackPart.
1-(I<110) is the same as (I>=110) which could look very similar to (I>220) that you are already plotting. All of the (I>220) would be included within the (I>=110)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by