# How to trace the minimum and maximum lines of the image of the moiré franges?

3 views (last 30 days)
ali alizadeh on 28 Sep 2023
Commented: ali alizadeh on 3 Oct 2023
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

Catalytic on 30 Sep 2023
Edited: Catalytic on 30 Sep 2023
Something like this might also work -
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));
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
Matt J on 30 Sep 2023
Nice! +1
ali alizadeh on 2 Oct 2023
Wow this is wonderful!
Thank you

Image Analyst on 2 Oct 2023
To see published algorithms on the topic, see
9.5.3 Optical Interferometry, Moire Patterns
Pick a paper and code up their algorithm.
ali alizadeh on 3 Oct 2023
Thank you for your suggestion. There are valuable articles in this link that will definitely help me.

### Categories

Find more on Image Data Acquisition in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!