How to prepare hyperspectral image data for convolutional neural network?

조회 수: 5 (최근 30일)
Daniel Thomas
Daniel Thomas 2017년 9월 14일
답변: Parth Parikh 2022년 11월 30일
In order to run convolutional neural network in neural network toolbox with grey or color image data, I can easily segment the images and locate them into proper category folders for datastore command.
But now I wonder how to run CNN with hyperspectral images as they have more than 3 channels and different file formats (.hyp or .img). Any hint or clue would be appreciated.

답변 (1개)

Parth Parikh
Parth Parikh 2022년 11월 30일
Hi Daniel,
We can crop the data and feed into augmentedImageDatastore. Suppose for the classification problem we would like to pass labels and hyperspectral data to datastore. Assume hyperspectral datacube size is 145x145x100 and label matrix size is 145x145.
% hcube = 3D datacube of size 145x145x100
% groundTruthLabel = 2D matrix of size 145x145.
winSize = 20;
padding = floor((winSize-1)/2);
zeroPaddingPatch = padarray(hcube,[padding,padding],0,'both');
[rows,cols,ch] = size(hcube);
patchData = zeros(rows*cols,winSize,winSize,ch);
patchLabel = zeros(rows*cols,1);
zeroPaddedInput = size(zeroPaddingPatch);
patchIdx = 1;
for i= (padding+1):(zeroPaddedInput(1)-padding)
for j= (padding+1):(zeroPaddedInput(2)-padding)
patch = zeroPaddingPatch(i-padding:i+padding,j-padding:j+padding,:);
patchData(patchIdx,:,:,:) = patch;
patchLabel(patchIdx,1) = groundTruthLabel(i-padding,j-padding);
patchIdx = patchIdx+1;
end
end
[allPatches,allLabels] = createImagePatchesFromHypercube(patchData,patchLabel,winSize);
We can partition allPatches and allLabels for traning and testing.
Similar example is available in hyperspectral support package:

카테고리

Help CenterFile Exchange에서 Display Point Clouds에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by