Clear Filters
Clear Filters

calculate 2D image from 3D data

1 view (last 30 days)
MENGZHI DI
MENGZHI DI on 11 Oct 2018
Commented: MENGZHI DI on 12 Oct 2018
Now I have the xyz data, and want to calculate the corresponding 2D image. The equations I am using is from shape from shading, I(i,j)=1/sqrt(p*p+q*q+1), p and q are the slope of the surface along the x and y directions, respectively. Here calculate them using discrete approximations, p=Z(i,j)-Z(i,j-1), q=Z(i,j)-Z(i-1,j). The result should be the above image, however what I get is the below one. Could someone give me some advice about this?
for i=1:numr
for j=1:numc
if (j==1)
p(i,j)=z(i,j+1)-z(i,j);
else
p(i,j)=z(i,j)-z(i,j-1);
end
if i==1
q(i,j)=z(i+1,j)-z(i,j);
else
q(i,j)=z(i,j)-z(i-1,j);
end
I(i,j)=1/sqrt(p(i,j)*p(i,j)+q(i,j)*q(i,j)+1);
end
end
  2 Comments
jonas
jonas on 11 Oct 2018
Could you upload the xyz data?
MENGZHI DI
MENGZHI DI on 12 Oct 2018
Thank you for replying. I put them in a 3x16384 matrix. The first row is x, second is y, third is z data.

Sign in to comment.

Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!