=20

=20

=20
=20

=20
=20

=20

This page summarizes some code sn= ippets on manipulation of HS cubes in Matlab.

=20

=20
=20

=20
=20

=20
=20

- =20
- Import and export of HS data into and from Matlab =20
- Code snippet on primitive data manipulation=20
- =20
- Concatenate = cubes =20
- Rotate cube=20
- Crop cube = =20
- Sub sample cube= =20

=20

=20

=20
=20

=20
=20
### Import and export of HS data into =
and from Matlab

### Code snippet on primitive data manipulation

#### Concatenate cubes<=
/h4>

#### Rotate cube

#### Crop cube

#### Sub sample cube

=20
Download LoadHSData Matlab function&n=
bsp;f=
rom the Matlab Scripts page and save it in your Ma=
tlab user directory.

Import the cube by the following command:

=20

[C,p,u]= =3D LoadHSData;=20

Do=
wnload SaveHSData Matlab function from the Matlab Scripts page and save it in your Matlab user directory.

Save a =
cube by the following command:

=20

SaveHSD= ata(C,p,u);=20

Please see detailed information about= file import and export possibilities in the File Import / Export documentation.

=20

[C1 p u= ] =3D LoadHSData;=09%load cube C1 from file [C2 p u] =3D LoadHSData;=09%load cube C2 from file %concatenate cubes along sample direction C3 =3D cat(3,C1,C2);=09=09 %concatenate cubes along spatial direction C3 =3D cat(1,C1,C2);=09=09 SaveHSData(C3,p,u);=09=09%save resulting cube C3 to file=20

=20

[C p u]= =3D LoadHSData;=09%load cube C from file %rotate cube in the pixel domain about 90 degree C=3Dpermute(C,[1 3 2]); C_=3Dzeros(size(C)); for i=3D1:size(C,3) =09C_(:,:,i) =3D rot90(C(:,:,i)); end C=3Dpermute(C_,[1 3 2]); SaveHSData(C,p,u);=09=09%save rotated cube C to file=20

=20

[C p u]= =3D LoadHSData;=09%load cube C from file %crop out a cube of size 11x11x11 beginning at spatial position 10, spectra= l position 10 and sample position 10 %Note: size of cube must match! - should be greater or equal to 20x20x20 in= this example ivROISpat =3D [10 20];=09=09 ivROISpec =3D [10 20];=09=09 ivROISamp =3D [10 20];=09 C =3D C( ivROISpat(1):ivROISpat(2) ,... ivROISpec(1):ivROISpec(2) ,... =09 ivROISamp(1):ivROISamp(2) ); SaveHSData(C,p,u);=09=09%save cropped cube C to file=20

=20

[C p u]= =3D LoadHSData;=09%load cube C from file %subsample each direction of cube C about factor 2 ivROISpat =3D 1:2:size(C,1);=09=09 ivROISpec =3D 1:2:size(C,2); ivROISamp =3D 1:2:size(C,3); C =3D C( ivROISpat ,... ivROISpec ,... =09 ivROISamp ); SaveHSData(C,p,u);=09=09%save sub sampled cube C to file=20

=20

=20
=20

=20
=20

=20

=C2=A9 2019 by Perception Park GmbH

The c=
ontent of this page and any attached files are confidential and intended so=
lely for the addressee(s). Any publication, transmission or other use of th=
e information by a person or entity other than the intended addressee is pr=
ohibited. If you receive this in error please contact Perception Park and d=
elete copied material. Perception Park GmbH, Wartingergasse 42, A-8010 Graz; Austria; FN 400381x