an inefficient 3D point viewer


Given a disparity map and a color image, want to view the 3D scene created by these 2 images:

clear;
% load images
Index=imread(‘disparity.bmp’);
C=double(imread(‘fly_1.jpg’))/255;

s = size(C);
m = s(1,1); % row
n = s(1,2); % columm

figure;
for x=1:1:m
for y=1:1:n
plot3(x, y, Index(x,y,1), ‘color’, [C(x,y,1), C(x,y,2), C(x,y,3)]), hold on;
end
end

执行的时候效率非常低,当还有1G free memory的时候就抱错说out of memory,估计是这种做法让Matlab觉得太恶心了。使用figure的3d旋转按钮多按了几次,结果连Matlab就直接退出了。
(用plot来画大量的点的时候效率就低,加上每个点都指定不同的color,估计就更不行了。)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s