current position:Home>The image is processed and analyzed to calculate the fringe spacing in the image

The image is processed and analyzed to calculate the fringe spacing in the image

2022-02-03 02:33:05 CSDN Q & A

The phenomenon and background of the problem
Operation results and error reporting contents
My solution ideas and tried methods
What I want to achieve


Refer to the answer 1:

Hello, classmate , The main process is to find out the position and inclination of the strip

clc; clearimg = imread('pic.png'); %  Read in the picture pic.png For example, the file name is this figure(1);imshow(img),title(' Original picture ');% Convert to grayscale image img=rgb2gray(img);% Convert to binary image BW=imbinarize(img); % High pass filter denoising sigma=1;% Standard deviation of filter parameters=double(3*sigma*2+1); %  Formwork size H=fspecial('gaussian', parameters, sigma);% Filter operator  %gaussian low pass filter BW=imfilter(BW,H,'replicate');% Ossification BW1=bwmorph(BW,'skel',20);% Deburring ( Eliminate noise )BW2=bwmorph(BW1,'spur',18);figure(2); clfimshow(BW2)[m,n,~] = size(BW2);nbd = floor(n/5);BW3  = BW2(nbd:end-nbd, nbd:end);imshow(BW3);[x,y] = find(BW3);p = polyfit(x,y,1); %  This step is mainly to solve the inclination p(1) = tan(theta)[X,Y] = meshgrid(1:n, 1:m);[x0, y0] = meshgrid(1:n, floor(m/2));z0 = interp2(X,Y,double(img)/255,x0,y0);figure(3); clfz0 = smooth(z0);plot(x0,z0)[pks, locs ]= findpeaks(z0); %  Find the highest white value BandLength = mean(diff(locs))*cos(atan(p(1))) %  Strip width , Count according to the number of pixels 




The final width is
BandLength =

Here is the width of such a pixel

Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.

Random recommended