Extracting wavelength vector from an .hdr file

12 views (last 30 days)
Hi all,
I am fairly new to MATLAB.
I'd like to extract a number of wavelengths as a vector from an .hdr file (see below). They are one value per line, preceded by four spaces, followed by a comma, and start at line 21 and stop at line 224 of the file.
How can I read them into matlab?
Thank you in advance!
.hdr file contents:
ENVI
description = {Data recorded with Specim IQ}
samples = 512
lines = 512
bands = 204
header offset = 0
file type = ENVI
data type = 12
interleave = BIL
sensor type = SPECIM IQ
byte order = 0
default bands = {70,53,19}
latitude = 0.00000000
longitude = 0.00000000
acquisition date = 23-05-2019
errors = none
binning = {1,1}
tint = 3
fps = 150
wavelength = {
397.32,
400.20,
403.09,
405.97,
408.85,
411.74,
414.63,
417.52,
420.40,
423.29,
426.19,
429.08,
431.97,
434.87,
437.76,
440.66,
443.56,
446.45,
449.35,
452.25,
455.16,
458.06,
460.96,
463.87,
466.77,
469.68,
472.59,
475.50,
478.41,
481.32,
484.23,
487.14,
490.06,
492.97,
495.89,
498.80,
501.72,
504.64,
507.56,
510.48,
513.40,
516.33,
519.25,
522.18,
525.10,
528.03,
530.96,
533.89,
536.82,
539.75,
542.68,
545.62,
548.55,
551.49,
554.43,
557.36,
560.30,
563.24,
566.18,
569.12,
572.07,
575.01,
577.96,
580.90,
583.85,
586.80,
589.75,
592.70,
595.65,
598.60,
601.55,
604.51,
607.46,
610.42,
613.38,
616.34,
619.30,
622.26,
625.22,
628.18,
631.15,
634.11,
637.08,
640.04,
643.01,
645.98,
648.95,
651.92,
654.89,
657.87,
660.84,
663.81,
666.79,
669.77,
672.75,
675.73,
678.71,
681.69,
684.67,
687.65,
690.64,
693.62,
696.61,
699.60,
702.58,
705.57,
708.57,
711.56,
714.55,
717.54,
720.54,
723.53,
726.53,
729.53,
732.53,
735.53,
738.53,
741.53,
744.53,
747.54,
750.54,
753.55,
756.56,
759.56,
762.57,
765.58,
768.60,
771.61,
774.62,
777.64,
780.65,
783.67,
786.68,
789.70,
792.72,
795.74,
798.77,
801.79,
804.81,
807.84,
810.86,
813.89,
816.92,
819.95,
822.98,
826.01,
829.04,
832.07,
835.11,
838.14,
841.18,
844.22,
847.25,
850.29,
853.33,
856.37,
859.42,
862.46,
865.50,
868.55,
871.60,
874.64,
877.69,
880.74,
883.79,
886.84,
889.90,
892.95,
896.01,
899.06,
902.12,
905.18,
908.24,
911.30,
914.36,
917.42,
920.48,
923.55,
926.61,
929.68,
932.74,
935.81,
938.88,
941.95,
945.02,
948.10,
951.17,
954.24,
957.32,
960.40,
963.47,
966.55,
969.63,
972.71,
975.79,
978.88,
981.96,
985.05,
988.13,
991.22,
994.31,
997.40,
1000.49,
1003.58
}

Answers (2)

Subhadeep Koley
Subhadeep Koley on 16 Nov 2020
You can use the enviinfo function to achieve the same.
% Load the HDR information
info = enviinfo('yourFile.hdr');
% Extract out the wavelength values
wavelengthValues = info.Wavelength;
The above mentioned feture comes under Image Processing Toolbox's Hyperspectral Imaging Library support package, and can be downloaded from here. For more information on Hyperspectral Imaging Library see the documentation.

R. Rocha de Oliveira
R. Rocha de Oliveira on 31 Jul 2019
Try to use "impot data" option in matlab. Usualy you can define the delimiters, start and end row.

Products

Community Treasure Hunt

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

Start Hunting!