clear all clc close all fftw('planner', 'exhaustive'); % afzayesh sorate barname a=rgb2gray(imread('f02.jpg')); % khandan va eslahe tasvir ag=im2double(a); agh=histeq(ag); b1=im2bw(agh,.24); subplot(1,2,1);imshow(b1) title('Binary of Original Image') [m n]=size(b1); b2=b1; haz=[]; % ijad yek tasvire tekrari baryae FFT for i=1:n k=find(0==b1(:,i)); if length(k)<300 haz=[haz,i]; end end b2(:,haz)=[]; subplot(1,2,2);imshow(b2) title('Modified Image') sotm=mean(b2,2); % ijad bordar motanaseb ba tarhe baft sotm2=mean(b2,1); sotm=im2bw(sotm); sotm2=im2bw(sotm2); fsot=abs(fft(sotm)); % mohasebeye FFT fsot2=abs(fft(sotm2)); figure subplot(2,1,1) plot(linspace(0,size(fsot,1),length(fsot)),fsot) % namayeshe FFT tarhe baft va yaftane ferekanse tekrar title('FFT for Finding Weft') fsot=fsot(length(fsot)/2:end); pik=round(max(fsot)); k=find(sotm>=mean(sotm)); % mohasebeye ghotre nakhe pood ghop=pik*length(k)/length(sotm); xlabel(['Weft Diameter : ',num2str(ghop),' pixel']) subplot(2,1,2) plot(linspace(0,size(fsot2,1),length(fsot2)),fsot2) title('FFT for Finding Warp') fsot2=fsot2(length(fsot2)/2:end); pik2=round(max(fsot2)); k2=find(sotm2<=mean(sotm2)); % mohasebeye ghotre nakhe tar ghot=pik2*length(k2)/length(sotm2); xlabel(['Warp Diameter : ',num2str(ghot),' pixel']) % mahasebeye tex tar o pood % Polyester density : 1.38 gr/cm^3 z=input('enter the zoom : '); texp=(ghop/2/z)^2*1.38*pi*10^5*.65; text=(ghot/2/z)^2*1.38*pi*10^5*.65; disp(['Weft tex : ',num2str(texp)]) disp(['Warp tex : ',num2str(text)])