Storing points into an array
Show older comments
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)';
Accepted Answer
More Answers (1)
Iain
on 8 Sep 2014
p = img(75, 104,:);
Categories
Find more on Read, Write, and Modify Image in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!