三维点云数据的处理有时需要借助对应的二维图像,进行平行投影后,虽然会损失诸多信息,但对于没有二维图像的数据来说,不失为一种借鉴,对于如何使信息损失降到最低,欢迎讨论哦~
tic fid=fopen('face1.txt'); % 打开文件 row=0; while ~feof(fid) [~]=fgets(fid); row=row+1; end fclose(fid); row; data2=zeros(row,6); data=load('face1.txt'); x=data(:,1);y=data(:,2);z=data(:,3);r=data(:,4);g=data(:,5);b=data(:,6); k=1; for m=1:length(x) data2(k,1)=ceil(x(m,1)+0.5); data2(k,2)=ceil(y(m,1)+0.5); % data2(k,1)=roundn(x(m,1),-1); % data2(k,2)=roundn(y(m,1),-1); data2(k,3)=z(m,1); data2(k,4)=r(m,1); data2(k,5)=g(m,1); data2(k,6)=b(m,1); k=k+1; end x_stand=unique(data2(:,1)); y_stand=unique(data2(:,2)); sort(x_stand); sort(y_stand); data2_2d=zeros(length(x_stand),length(y_stand),3); for i=1:length(x_stand) for j=1:length(y_stand) data2_2d(i,j,1)=255; data2_2d(i,j,2)=255; data2_2d(i,j,3)=255; end end for i=1:row index_x=find(x_stand==data2(i,1)); index_y=find(y_stand==data2(i,2)); data2_2d(index_x,index_y,1)=data2(i,4); data2_2d(index_x,index_y,2)=data2(i,5); data2_2d(index_x,index_y,3)=data2(i,6); end figure(); data2_2d=uint8(data2_2d); imshow(data2_2d,[]); imwrite(data2_2d,'face1.jpg'); % image(data2_2d); % subplot(1,2,1); % data2_2d=uint8(data2_2d); % imshow(data2_2d,[]); % imwrite(data2_2d,'face2.jpg'); % subplot(1,2,2); % A=imrotate(data2_2d,90,'nearest','crop'); % imshow(A); % imwrite(A,'rotated face2.jpg'); toc