I have a floor plan in a .jpeg or .png file, that I can read and display with the function image with the x-y coordinates. I also have another quantity, z, for a few, N, selected x-y locations of the floor coordinates. I would like to draw 3D bars at the appropriate N locations corresponding to the values of z. Would appreciate any help to do this.

 Respuesta aceptada

Rishabh Rathore
Rishabh Rathore el 31 de Mayo de 2018
Editada: Rishabh Rathore el 31 de Mayo de 2018

1 voto

You can plot image as a surface (on x-y plane) using the following code
%Insert Image
Z=imread('img.jpg');
[X,map]=rgb2ind(Z,256);
x=1:25; %change x,y to suite your requirements
y=1:25;
[xx,yy]=meshgrid(x,y);
zz=zeros(size(xx));
colormap(map)
surf(xx,yy,zz,X,'FaceColor','texturemap','EdgeColor','none','CDataMapping','direct');
After that use the function provided in the link below to plot the bar graph.

3 comentarios

Ranjan Sonalkar
Ranjan Sonalkar el 31 de Mayo de 2018
Not clear what format z_data is to go in the code. My image file consists of 5421x7335x3 uint8 pixels, and I have a 16-dimensional vector to plot as the bars, which I presume would be formatted into z_data. The bar locations are specified by 16-dimensional x and y co-ordinates.
Thanks
Rishabh Rathore
Rishabh Rathore el 31 de Mayo de 2018
As for plotting of image is concerned, the size would be adjusted to fit your x,y grid, you probably won't have to worry about it. And for bar graph I have changed my answer a bit, please check that out.
Ranjan Sonalkar
Ranjan Sonalkar el 31 de Mayo de 2018
that works. Thanks for the help.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Convert Image Type en Centro de ayuda y File Exchange.

Productos

Versión

R2017b

Preguntada:

el 30 de Mayo de 2018

Comentada:

el 31 de Mayo de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by