Storing points into an array
이전 댓글 표시
I have a Hyper-spectral image that is 760 X 520 X 361 which is also known as a data cube. I know if i want to find the value of a single pixel I would say Let p be the value/point and img be the image so therefore
p = img('75,104,361');
it should return a 1X1X361 matrix but instead i get a 1x10 what am i doing wrong? My other problem is I have a text file we will call "listp.txt" with 12 different points in it (i.e.75,104,361)( I tried in the below code to call list). How do i create a loop to call this list to p so that they can be stored as an array?
old=cd('C:\Users\Blarg\Desktop\Hal');
%%Get Full Image Data
% ENVI Import Cube and Register images
datafile = 'image_FlatField';
hdrfile = 'image_FlatField.hdr';
%%Read ENVI Files
[im, hdr] = enviread([old '\' datafile],[old '\' hdrfile]);
img = imrotate(im,90, 'nearest');
figure; imshow(img(:,:,361));
%%Reshape .txt into 12x1 list with each coordinate read in a columns as
% | 1 | 2 ...
%1| '342,212,361' |
%2| '313,147,361' |
%3| '295,212,361' |
%4 ...
d = reshape(textread('listp.txt', '%s'),1,12)';
채택된 답변
추가 답변 (1개)
Iain
2014년 9월 8일
p = img(75, 104,:);
카테고리
도움말 센터 및 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!