3D matrix mapping and manipulation
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Geoff Hayes
2014-9-2
Shane - if img is your 768x320x361 matrix/image, then to get a specific pixel value, just do
pixVal = img(113,341,361);
采纳的回答
Gitesh Nandre
2014-9-2
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;
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!