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

1 visualización (últimos 30 días)
Houghton
Houghton el 18 de Ag. de 2015
Comentada: Walter Roberson el 19 de Ag. de 2015
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 comentarios
Image Analyst
Image Analyst el 19 de Ag. de 2015
What do you want to do? Do you want to visualize the 3D color gamut, like this:
Houghton
Houghton el 19 de Ag. de 2015
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.

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 18 de Ag. de 2015
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 comentario
Walter Roberson
Walter Roberson el 19 de Ag. de 2015
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().

Iniciar sesión para comentar.

Categorías

Más información sobre Images en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by