3D matrix mapping and manipulation
조회 수: 1 (최근 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개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!