3D matrix mapping and manipulation

3 Ansichten (letzte 30 Tage)
Shane
Shane am 2 Sep. 2014
Beantwortet: Gitesh Nandre am 2 Sep. 2014
I have a 768x320x361 matrix which is my image(Which is a Hyper-Spectral image). How would I call or get a specific pixel value such as 113:341:361. The goal of this is to take the values of 30 different "Select" pixels and repopulate them randomly into a 30x30x361 matrix. Any guidance on this will be appreciated, thanks.
  1 Kommentar
Geoff Hayes
Geoff Hayes am 2 Sep. 2014
Shane - if img is your 768x320x361 matrix/image, then to get a specific pixel value, just do
pixVal = img(113,341,361);

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Gitesh Nandre
Gitesh Nandre am 2 Sep. 2014
As Geoff has correctly suggested, you can get a specific pixel value for a specific index such as 113:314:361 as follows:
pixVal = img(113,314,361) %where 'img' is your image matrix of the dimension 768x320x361.
In order to perform the next task, i.e. to randomly distribute 30 such specific pixel values in 30x30x361 matrix say 'mat', you can do following steps:
%First get all 30 values which you want to randomly distribute and put them into an array of dimention 1 x 30
%For demonstration purposes, I am generating random 30 values.
values = rand(1,30);
%Now generate the random 30 linear indices for the destination matrix 'mat' and put them into the array 'randIndices'.
randIndices = randi(30*30*361,1,30);
%Now , just assign the values to the locations pointed by these indices in matrix 'mat'
mat(randIndices) = values;

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by