MATLAB Answers

how can i show my hyperspectral data in a two dimensional projection of hyperspectral cube?

5 views (last 30 days)
asmaa elyamany
asmaa elyamany on 22 Jun 2020
Answered: Matthew on 2 Jul 2020
i have a hyperspectral data in a .m file it is 984*740*224 how can i show it in a two dimensional projection of hyperspectral cube?

  5 Comments

Show 2 older comments
Rik
Rik on 23 Jun 2020
The source is not really relevant. It is a 3D volume with a specific value range. Most CT and MRI viewers should work if you don't have a specific way to reduce those dimensions.
asmaa elyamany
asmaa elyamany on 23 Jun 2020
i used the VolumeViewer3D in the medical image viewer but it didn't view the image in a cube and it was somehow in greyscale but my data supose to be colorful
Rik
Rik on 23 Jun 2020
There are bound to be viewers that show the 3 directions and allow you to set a colormap to your liking.

Sign in to comment.

Accepted Answer

Matthew
Matthew on 22 Jun 2020
Edited: Matthew on 23 Jun 2020
If your data is something like (x,y,spectra), you could try:
imagesc(your_data(:,:,1));
If your data is like (spectra, x, y) you could try:
imagesc(squeeze(your_data(10,:,:)));

  11 Comments

Show 8 older comments
asmaa elyamany
asmaa elyamany on 28 Jun 2020
the output of my data was like this
[Xdim,Ydim,Spectra_dim]=size(HypeRvieW)
Xdim =
984
Ydim =
740
Spectra_dim =
224
somehow when i run your code the X ,Y and Spectra is 740*984*224
Matthew
Matthew on 29 Jun 2020
We just need to switch what's being labeled as x and y in the code I gave you remember that matlab uses row-major dimension ordering.
[Ydim,Xdim,Spectra_dim]=size(your_data);%should be Ydim = 984, Xdim=740, Spectra_dim=224.
[X Y Spectra]=meshgrid(1:Xdim,1:Ydim,1:Spectra_dim);%each array shoudl be 984x740x224
figure;
surf(squeeze(X(1,:,:)),squeeze(Y(1,:,:)),squeeze(Spectra(1,:,:)),squeeze(your_data(1,:,:)),'EdgeColor','none');
hold on;
surf(squeeze(X(end,:,:)),squeeze(Y(end,:,:)),squeeze(Spectra(end,:,:)),squeeze(your_data(end,:,:)),'EdgeColor','none');
surf(squeeze(X(:,1,:)),squeeze(Y(:,1,:)),squeeze(Spectra(:,1,:)),squeeze(your_data(:,1,:)),'EdgeColor','none');
surf(squeeze(X(:,end,:)),squeeze(Y(:,end,:)),squeeze(Spectra(:,end,:)),squeeze(your_data(:,end,:)),'EdgeColor','none');
surf(squeeze(X(:,:,1)),squeeze(Y(:,:,1)),squeeze(Spectra(:,:,1)),squeeze(your_data(:,:,1)),'EdgeColor','none');
surf(squeeze(X(:,:,end)),squeeze(Y(:,:,end)),squeeze(Spectra(:,:,end)),squeeze(your_data(:,:,end)),'EdgeColor','none');
asmaa elyamany
asmaa elyamany on 2 Jul 2020
the code is very helpful but the image displayed is blue while i want it to be coloful and may i ask you how to ratate it to make the image in the front not in the top

Sign in to comment.

More Answers (1)

Matthew
Matthew on 2 Jul 2020
To control the orientation of the image, read the documentation for 3-D camera control:
Specifically read the documentation for view:
There's also a button in the graphic windows to manually orbit the camera around.
As for the color, please study the documentation for colormap and caxis
As always when reading the documentation, pay attention to links to other function and the see also section to see related functions. Following these links will lead you to examples of related tasks and provide a broader view of the tools you have at your disposal.

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by