I want to plot 3D color image from data in array by using Plot3

2 次查看(过去 30 天)
I have x,y,z and RGB in array.
objectpoint_x_array=zeros(hightl,widthl,1);
objectpoint_y_array=zeros(hightl,widthl,1);
objectpoint_z_array=zeros(hightl,widthl,1);
objectpoint_color_array=zeros(hightl,widthl,3);
plot3 (objectpoint_x_array(:), objectpoint_y_array(:), objectpoint_z_array(:),'Color' , [objectpoint_color_array(:,:,1) objectpoint_color_array(:,:,2) objectpoint_color_array(:,:,3)]);
There is an error.
" Error using plot3
Color value must be a 3 or 4
element vector "
  3 个评论
Image Analyst
Image Analyst 2015-8-19
What do you want to do? Do you want to visualize the 3D color gamut, like this:
Houghton
Houghton 2015-8-19
I calculate (x,y,z) coordinate from images and I want to plot them in 3D where each coordinate will show the color from the reference image.

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2015-8-18
You cannot use the 'Color' parameter of plot3() to designate more than one color.
plot3() generates one lineseries object for each column of Z. You can loop through the line handles giving each of the handles a different color. You cannot, however, give each point a different color.
If you want to give each point a different color then you need to use scatter3() or you need to use patch()
  1 个评论
Walter Roberson
Walter Roberson 2015-8-19
plot3() is primarily for drawing lines that might or might not have markers on them: the data is in some way ordered . plot3() creates lineseries objects. Each lineseries object can have only a single color and single marker shape. The only way to use plot3() with one color for each point would be if you plotted one point at a time, which is possible but not pleasant code.
The routine for plotting in 3D with potentially different colors for each point is scatter3(), which is happy to take an N x 3 color matrix where N is the number of points being plotted. But scatter3() is for unordered data and cannot draw lines between the points.
If you want both lines and per-point coloring then you need to use patch(), and you need to decide what color you want each line to be. You currently have data about vertex colors but no indication of how to decide the color of lines joining the vertices, since the vertices may be different colors. patch() offers a few different options as to how to determine the color for lines.
Considering the task described it sounds to me as if scatter3() would be fine, but I cannot be sure as you did try to use the line-drawing routine plot3().

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by