필터 지우기
필터 지우기

3D matrix mapping and manipulation

조회 수: 1 (최근 30일)
Shane
Shane 2014년 9월 2일
답변: Gitesh Nandre 2014년 9월 2일
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
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
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개)

카테고리

Help CenterFile 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!

Translated by