Clear Filters
Clear Filters

Score ICS from hyperspectral raw file - HyTexiLa dataset

2 views (last 30 days)
Please help me!
I want to calculate and descending order ICS scores from .raw file of hyperspectral image in HyTexiLa dataset.
Thanks!

Answers (1)

Abhishek Tripathi
Abhishek Tripathi on 19 Apr 2024
Thanks for reaching out to us. In the domain of hyperspectral imaging, various terms like ICS have been introduced. Given that HyTexiLa is a dataset of hyperspectral texture images, I'm assuming you're using "ICS" to refer to Image Cube Statistics.
At present, our hyperspectral support package doesn't directly facilitate these functionalities. However, you can achieve this by following these steps to calculate and exhibit the ICS scores in descending order from a .raw file of a hyperspectral image in the HyTexiLa dataset:
  1. Load the Hyperspectral Image: You can use the hypercube, multiband, or load function to extract hyperspectral image data from the .raw file.
  2. Compute ICS Scores: Implement the algorithm to compute the ICS (Image Cube Statistics) scores for each pixel in the hyperspectral image. These scores typically involve statistical metrics like mean, variance, skewness, kurtosis, etc., calculated for each pixel across the spectral bands. Some functionalities are available in MATLAB.
  3. Sort ICS Scores: Once you've computed the ICS scores for each pixel, arrange them in descending order. This arrangement will provide you with a ranked list of pixels based on their ICS scores.
  4. Display the Results: Depending on your preference, you can exhibit the sorted list of pixels alongside their respective ICS scores, or you can visualize the hyperspectral image with pixels color-coded according to their ICS scores. For a better understanding of the spatial distribution of ICS scores, you may opt to visualize the sorted ICS scores on a map or image. This visualization can aid in identifying regions of interest or anomalies in the hyperspectral data.
  2 Comments
Tien
Tien on 19 Apr 2024
Thanks for your help!
First, I extract hyperspectral image data from the .raw file to hypercube & save them.
% Specify the file details
filename = '/MATLAB Drive/Hyperspectral/raw/food_coffee.raw'; % Replace 'your_file.raw' with your raw file name
rows = 1024; % Number of rows in the hyperspectral image
cols = 1024; % Number of columns in the hyperspectral image
bands = 186; % Number of spectral bands in the hyperspectral image
% Open the raw file for reading
fid = fopen(filename, 'rb');
% Read the raw data into a 1D array
raw_data = fread(fid, rows * cols * bands, 'float');
% Close the file
fclose(fid);
% Reshape the raw data into a hypercube (3D array)
hypercube = reshape(raw_data, rows, cols, bands);
% Specify the output .mat file name
output_filename = 'hyperspectral_data.mat';
% Save the hypercube as a .mat file
save(output_filename, 'hypercube');
Tien
Tien on 19 Apr 2024
Second, Compute ICS Scores that means Intra-Class Separability
% Load the hyperspectral data from the .mat file
load('/MATLAB Drive/hyperspectral_data.mat'); % Replace 'hyperspectral_data.mat' with the actual file name if different
% Get the dimensions of the hyperspectral data
[rows, cols, bands] = size(hypercube);
% Reshape the hypercube into a 2D array for easier computation
reshaped_data = reshape(hypercube, rows * cols, bands);
% Compute the mean spectrum across all pixels
mean_spectrum = mean(reshaped_data);
% Compute the standard deviation spectrum across all pixels
std_spectrum = std(reshaped_data);
% Compute the ICS scores for each pixel and each band
ICS_scores = zeros(rows * cols, bands);
for i = 1:(rows * cols)
pixel_spectrum = reshaped_data(i, :);
for j = 1:bands
ICS_scores(i, j) = abs(pixel_spectrum(j) - mean_spectrum(j)) / std_spectrum(j);
end
end
% Reshape the ICS scores back into the original image dimensions
ICS_scores = reshape(ICS_scores, rows, cols, bands);
% Display or use the ICS scores as needed
disp('ICS scores computed successfully.');
% Example usage: Accessing ICS scores for a specific pixel and band
row_index = 10; % Example row index
col_index = 15; % Example column index
band_index = 5; % Example band index
ICS_score = ICS_scores(row_index, col_index, band_index);
fprintf('ICS score for pixel at row %d, column %d, band %d: %.4f\n', row_index, col_index, band_index, ICS_score);

Sign in to comment.

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!