close all; clear all; clc;
%Displaying the hyperspectral images sample
%Make sure to download and install the Hyperspectral Image Processing Toolbox on MATLAB first before running codes
% Read image
%Valuez lines = 1200 samples = 900 bands = 300
img = multibandread('EB3 lower 220823.bil',[1042 900 300],'uint16',0,'bil','ieee-le');
% Read Bands nº 300
wavelength = [ 388.62 390.63 392.63 394.64 396.64 398.65 400.66 402.66 404.68 406.68 408.7 410.7 412.72 414.74 416.74 418.76 420.78 422.8 424.82 426.84 428.86 430.87 432.9 434.92 436.94 438.96 440.98 443.0 445.04 447.06 449.08 451.12 453.14 455.18 457.2 459.24 461.27 463.3 465.34 467.37 469.41 471.44 473.48 475.52 477.56 479.6 481.64 483.68 485.72 487.76 489.81 491.85 493.9 495.94 497.99 500.04 502.09 504.14 506.19 508.24 510.29 512.34 514.4 516.46 518.51 520.57 522.62 524.68 526.74 528.81 530.86 532.92 534.98 537.04 539.12 541.17 543.24 545.31 547.38 549.44 551.51 553.58 555.65 557.72 559.79 561.87 563.94 566.02 568.09 570.17 572.25 574.32 576.4 578.48 580.56 582.64 584.72 586.81 588.89 590.98 593.06 595.15 597.24 599.32 601.41 603.5 605.59 607.68 609.78 611.86 613.96 616.06 618.15 620.24 622.34 624.44 626.54 628.64 630.74 632.84 634.94 637.05 639.15 641.26 643.36 645.46 647.57 649.68 651.79 653.9 656.01 658.12 660.23 662.34 664.46 666.57 668.68 670.8 672.92 675.04 677.16 679.27 681.39 683.52 685.64 687.76 689.88 692.01 694.13 696.26 698.38 700.51 702.64 704.77 706.9 709.03 711.16 713.3 715.43 717.56 719.7 721.84 723.98 726.1 728.24 730.38 732.52 734.66 736.8 738.96 741.1 743.24 745.38 747.53 749.68 751.82 753.97 756.12 758.27 760.42 762.57 764.72 766.88 769.03 771.19 773.34 775.5 777.66 779.82 781.97 784.13 786.3 788.46 790.62 792.78 794.95 797.11 799.28 801.44 803.61 805.78 807.95 810.12 812.29 814.46 816.63 818.8 820.98 823.16 825.33 827.5 829.68 831.86 834.04 836.21 838.4 840.58 842.76 844.94 847.13 849.32 851.5 853.68 855.88 858.06 860.25 862.44 864.63 866.82 869.02 871.21 873.4 875.6 877.79 879.99 882.18 884.38 886.58 888.78 890.98 893.18 895.39 897.59 899.79 902.0 904.2 906.41 908.62 910.82 913.03 915.24 917.46 919.66 921.88 924.09 926.3 928.52 930.73 932.94 935.16 937.38 939.6 941.82 944.04 946.27 948.48 950.7 952.94 955.16 957.38 959.6 961.84 964.06 966.29 968.52 970.75 972.98 975.21 977.44 979.68 981.91 984.15 986.38 988.62 990.86 993.1 995.34 997.58 999.82 1002.06 1004.3 1006.55 1008.79 1011.04 1013.28 1015.53 1017.78 1020.03 1022.28 1024.53];
hcube = hypercube(img,wavelength); 

% Display the image
rgbImg = colorize(hcube,'Method','RGB','ContrastStretching',true); 
figure(1), imshow(rgbImg)

row = 291:1314;
column = 360:1383;

% Crop the Region Of Interest (ROI)
cropped_hcube = cropData(hcube,row,column,':');

% Display the cropped image
rgbImg2 = colorize(cropped_hcube,'Method','RGB','ContrastStretching',true); 
figure(2), imshow(rgbImg2)