How to trace the minimum and maximum lines of the image of the moiré franges?
2 次查看(过去 30 天)
显示 更早的评论
I have a photo of the stripes that I am posting as an example (orginal moire). How can you find the middle points of these light and dark lines by MATLAB and connect these lines with a line? I have also included an example of this image (moire with lines).
The pixel coordinates of these found lines should be stored in the matrix.
The second photo ( moire with lines) that is attached contains dark + light lines + the border between dark and light lines
0 个评论
采纳的回答
Catalytic
2023-9-30
编辑:Catalytic
2023-9-30
Something like this might also work -
A=load('Image').Image;
T=findEdges(A,'top',10);
B=findEdges(A,'bottom',10);
C=findCenter(T,B);
imshow(A,[]);
hold on
for i=1:numel(T)
h=plot(T(i).x,T(i).y,'LineWidth',2);
plot(B(i).x,B(i).y,'LineWidth',2,'Color',h.Color);
plot(C(i).x,C(i).y,'--','LineWidth',2,'Color',h.Color);
end
hold off
function Line=findEdges(A,sense,n)
outside=imerode(~bwconvhull(A>150),strel('disk',5));
[~,S]=gradient(sgolayfilt(A,2,21,[],1));
if strcmp(sense,'bottom'), S=-S; end
B=(movmax(S,11,1)==S);
B(outside)=0;
B=imclose(B>0,strel('disk',4));
B=bwareafilt(B,n);
B=bwmorph(B,'thin');
rp=regionprops(B,'PixelList');
for i=numel(rp):-1:1
x=rp(i).PixelList(:,1);
y=rp(i).PixelList(:,2);
p=polyfit(x,y,4);
x=linspace(min(x),max(x),size(A,2));
y=polyval(p,x);
Line(i).x=x;
Line(i).y=y;
Line(i).ym=mean(y);
end
[~,reorder]=sort([Line.ym]);
Line=Line(reorder);
end
function Line=findCenter(T,B)
for i=numel(T):-1:1
Line(i).x=(T(i).x+B(i).x)/2;
Line(i).y=(T(i).y+B(i).y)/2;
Line(i).ym=[];
end
end
更多回答(1 个)
Image Analyst
2023-10-2
To see published algorithms on the topic, see
9.5.3 Optical Interferometry, Moire Patterns
Pick a paper and code up their algorithm.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!