# How do I delete the last dimension of a 256*256*3 matrix?

19 vues (au cours des 30 derniers jours)
Diptayan Dasgupta le 12 Mai 2021
I want to get rid of the "*3" part. That's the code I used. The image shouldn't be a multidimentional array.
figure; imshow(Ii);
title('Object pattern')
axis off
Ii=double(Ii);
PH=rand([256,256]);
Ii=Ii.*exp(2i*pi*PH); % add a random phase on the object
M=512;
I=zeros(512);
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Daniel Pollard le 12 Mai 2021
Is Ii your 256x256x3 array? An image of 256x256 pixels will have 256x256x3 elements because of the red, green and blue elements.
To remove that third dimension, you could extract only one of the layers;
Ii = Ii(:,:,1);
You could average over the layers;
Ii = sum(Ii, 3)./3;
These options will result in Ii having size 256x256, removing the third dimension, but will also remove information that may be useful.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Images dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by