matlab exercise program (image projection point cloud)

More recently cloud point of contact, if the image is projected to a point cloud should be quite interesting.

We first need to load the image, and then make a ball or whatever the shape of the point cloud, where you can refer to spherical coordinates formula.

Finally, the pixel output to the cloud point by pcshow.

Original:

After the projected point cloud:

 

code show as below:

clear all;
close all;
clc;

img = imread('lena.jpg');

[m,n,d]=size(img);
I=reshape(img,[],d);   

R=1;
x=zeros(m*n,1);
y=zeros(m*n,1);
z=zeros(m*n,1);
num = 0;

%做个球。。。
for j=-pi/2:pi/n:pi/2-pi/n   
    for i=0:2*pi/m:2*pi-2*pi/m
        
        num=num+1;
        x(num) = R.*cos(j).*cos(i);
        y(num) = R.*sin(j).*cos(i);
        z(num) = R.*sin(i);
        
    end
end

pcshow([x y z],[I I I]);    %如果是彩色图:pcshow([x y z],I);

Benpian reference matlab is written in pcshow example, is an example of the difference between no explicit formula for writing spherical coordinates, in fact, it is similar, using the panorama effect should be better.

matlab help documentation:

https://ww2.mathworks.cn/help/vision/ref/pcshow.html?requestedDomain=cn

Guess you like

Origin www.cnblogs.com/tiandsp/p/11613889.html