matlab - 将图像放在matlab 3D散点图的XY平面中
问题描述
我正在尝试将图像放在 3D 散点图的 XY 平面上。我拥有的当前版本给出了一些结果,但图像的颜色显示不正确。
目前,我将图像作为灰度读取,但理想情况下我希望将我的点放在彩色图像之上。
x = [1,2,3,4,5,6,7,8,9,10,11,1,2,3,4,5,6,7,8,9,10,11];
y = [0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1];
z = [0,0,0,1,2,3,2,1,0,0,0,0,0,1,2,3,2,1,0,0,0,0];
min_x = min(min(x));
min_y = min(min(y));
max_x = max(max(x));
max_y = max(max(y));
planeimg = rgb2gray(imread('1.jpg'));
figure; hold on;
scatter3(x,y,z);
colormap(gray);
minplaneimg = min(min(planeimg)); % find the minimum
scaledimg = (floor(((planeimg - minplaneimg) ./ ...
(max(max(planeimg)) - minplaneimg)) * 255)); % perform scaling
imgzposition = -10;
colorimg = ind2rgb(scaledimg,jet(256));
surf([min_x max_x],[min_y max_y],repmat(imgzposition, [2 2]),...
colorimg,'facecolor','texture')
view(45,30);
xlabel('x');
ylabel('y');
zlabel('z');