close all clear all center=166; %266 % rotational center (in pixels) in the pictures emnetop=1; % top (in pixels) of the object in the picture emnebund=240; % bottom (in pixels) of the object in the picture Roedgraense=100; % Sensitivity (Detecting the red-intensity) antal=424; % No. of prctures (normally 360) span=2; % smoothing for k=1:antal k i=1; [pix,map] = imread([num2str(k)],'bmp'); [yz,xz,flemming]=size(pix); for x=emnetop:emnebund foundpixel=0; for y=1:xz R(y,1)=pix(x,y,1); %G(y,1)=pix(x,y,2); %B(y,1)=pix(x,y,3); if pix(x,y,1) > Roedgraense xer(i,k)=center-y; yer(i,k)=emnebund-x; i=i+1; foundpixel = 1; break end end if foundpixel == 0 & i==1 xer(i,k)=0; yer(i,k)=emnebund-x; i=i+1; elseif foundpixel == 0 xer(i,k)=xer(i-1,k); yer(i,k)=emnebund-x; i=i+1; end end % udglatning xer(:,k)= smooth(xer(:,k),span); yer(:,k)= smooth(yer(:,k),span); end for i=1:emnebund-emnetop xer(i,:)= smooth(xer(i,:),span); yer(i,:)= smooth(yer(i,:),span); end % hold on ;plot(R,'r');plot(G,'g');plot(B,'b') %hold on %plot(xer,yer) % Plotting ---------------------------------------------------------- xer(:,k+1)=xer(:,1); yer(:,k+1)=yer(:,1); j=1; for theta=0:(2*pi/antal):2*pi theta for i=1:numel(xer(:,1)) R=(xer(i,j))/(sin(pi/4)); X(i,j)=R*cos(theta)*1; Y(i,j)=R*sin(theta)*1; Z(i,j)=yer(i,j)*1; end % plot3(X(:,j),Y(:,j),Z(:,j)); j=j+1; end figure surface(X,Y,Z); %h = camlight('left'); axis vis3d axis equal shading flat view([0,1,0]) title('3D scanning'); xlabel('X'); ylabel('Y'); zlabel('Z');