Finding the particular path using image processing

조회 수: 11 (최근 30일)
waqas
waqas 2020년 8월 24일
댓글: waqas 2020년 11월 22일
Hi,
I need to find the path from the attached displacement field attached as .MAT file. My code was working on other data sets that I was analyzing but is not working for the new data set I have.
Currently I am using following code:
Igray = mat2gray(dispfield);
th = multithresh(Igray,2);
Iseg = imquantize(Igray,th);
se = strel('disk',1);
BW1 = bwperim(Iseg == 1);
BW1 = imdilate(BW1,se);
BW2 = bwperim(Iseg == 2);
BW2 = imdilate(BW2,se);
BWedge = BW1 & BW2;
BWedge = bwmorph(BWedge,'skel',Inf);
bwedge = BWedge;
[Y,X] = find(bwedge);
cracklinefit = fit(X,Y,'poly3','Normalize','on');
% cracklinefit = fit(X,Y,'poly3','Normalize','on','Robust','Bisquare');
outputArg3 = [1:size(bwedge,2)]';
outputArg2 = round(cracklinefit(outputArg3));

채택된 답변

Madhav Thakker
Madhav Thakker 2020년 9월 8일
Hi Waqas,
I understand that you want to calculate path from the given .MAT file. I see that your code was not working for this example due to some distortions.
One useful function to use here is bwareaopen() which removes all connected components (objects) that have fewer than P pixels from the binary image.
I am attaching a code snippet for better understanding.
Igray = mat2gray(dispfield);
th = multithresh(Igray,1);
Iseg = imquantize(Igray,th);
%imshow(Iseg,[])
se = strel('disk',1);
BW1 = bwperim(Iseg == 1);
BW1 = imdilate(BW1,se);
bwedge = bwareaopen(BW1, 100); % removes all connected components (objects) that have fewer than P pixels
[Y,X] = find(bwedge);
cracklinefit = fit(X,Y,'poly3','Normalize','on');
% cracklinefit = fit(X,Y,'poly3','Normalize','on','Robust','Bisquare');
outputArg3 = [1:size(bwedge,2)]';
outputArg2 = round(cracklinefit(outputArg3));
Hope this helps.
  댓글 수: 1
waqas
waqas 2020년 11월 22일
it ended up helping me in another implementation. Thank you.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Import, Export, and Conversion에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by