我正在尝试将图像放置在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');