How can I display a 3D image of a 10x10x10 matrix? Each cube has a value between 1-10.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a 2D matrix s(10,10). So, there are 100 squares. Each square has a value between 1-10. So, I can display the matrix with imagesc(s) function. The image is like the following. s represents the bottom right. The squares in the below picture have values between 1 or 2
Now I want to extend the matrix to 3D, which is s(10,10,10) and has 1000 cubes , each having a value between 1-10. How can I display it like the following image with each cube colored by their respective values?
0 Kommentare
Antworten (1)
Bjorn Gustavsson
am 17 Okt. 2022
Bearbeitet: Bjorn Gustavsson
am 17 Okt. 2022
You should be able to generate a figure like the cube you show by utilizing the slice-function. Something like this:
% Mocking up some 10x10x10 data
s10by10by10 = round(convn(10*rand(10,10,10),ones(2,2,2)/8,'same'));
% displaying with slice
slice(s10by10by10([1:end,end],[1:end,end],[1:end,end]),[1 11],[1 11],[1,11])
You might have to play around with the colour-map to get a nice display:
colorbar
cmp = jet(10);
colormap(cmp(randperm(size(cmp,1)),:)) % To get increased contrast between regions with similar values
HTH
7 Kommentare
Bjorn Gustavsson
am 25 Jan. 2023
@MD MAHABUBUR ROHOMAN, yes, that might work. Just try, and read the help and documentation of slice to see what other modifications you might be interested in.
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!