Separating the Z Vector of a matrix

6 vues (au cours des 30 derniers jours)
Shane
Shane le 15 Sep 2014
Réponse apportée : Shane le 30 Sep 2014
Say we have a Data Cube that is 768x320x361(i.e. X, Y, Z coordinates). I generate 2 variable list called VarName1 and VarName2 that hold X and Y coordinates. My goal is to get only the first 124 values of the Z vector at each X and Y point and assign the values to columns. Here is the code I have wrote so far
pixswir=zeros(361,12);
for i = 1:12
%grabs all the pixel values in the z direction
pix = img(VarName2(i),VarName1(i),:);
pixswir(:,i)=pix(:);
end
This will return a matrix 361 x 12 but I only want to grab the first 124 data points of the Z vector and assign them to pixswir so that i have a 124 x 12 matrix. The rest of the values i wish to assign to pixVnir in a 231 x 12 matrix( NOTE:the points on the Z vector 125 to 129 are transition data that is not needed). Any help would be grateful I have tried a few things and keep getting "Subscripted assignment dimension mismatch"

Réponse acceptée

Shane
Shane le 30 Sep 2014
Because of the disparity in the two sensors I had to read in the two sensors independently. The sensor one is the fist 124 bands and sensor two 231 bands. to do this I created 2 zeros mask that could be use to fill
pixswir=zeros(231,length(listp));
pixVnir=zeros(124,length(listp));
The first vector of wavelength was grabbed using a for loop to match each point to my list of points which I called VarName2 for y and VarName1 for x coordinates.
for i = 1:length(listp)
%grabs all the pixel values in the z direction
pix = img(VarName2(i),VarName1(i),:);
pixVnir(:,i)=pix(1:124);
end
I used a similar posses for the other set but i had to create a new x coordinate based on the offset of the two sensors i.e.
tempVar=zeros(length(listp),1);
for ii = 1:length(listp)
tempVar(ii)=VarName1(ii)+Disoffset(ii);
end
Then it could be pressed the same as the first only with the tail end of the bands "pixswir(:,i)=pix2(131:end);" This allowed me to append the images to for a new 355 by 20 matrix with each column containing the z vector of that pixel

Plus de réponses (0)

Catégories

En savoir plus sur Hyperspectral Image Processing dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by