Converting 2-D array back to image??

I am trying to apply a neural network that was trained on 2-D array data extracted from an image. I can successfully apply the trained network to the original image (2441,758,21) if I convert it to 2-D array (rows,columns*bands) = (2441,15918) then using cca fusion the band information is fused to a single band (2441,1) and used as the input data for the network. The resulting predicted values 't_img' are the shape (2441,1). How can this be mapped back to an image for display?
% reshape to 2-D array
img = reshape(im,2114,758*21);
normData = mapminmax(img);
TrainingData = normData(1:1000,1:end);
TestingData = normData(1001:end,1:end);
x = TrainingData(:,2:end);
y = TrainingData(:,7000);
y1 = TestingData(:,7001);
% Feature Fusion CCA %
[trainZ,testZ] = ccaFuse(x, y, TestingData(:,2:end), y1, 'sum');
trainZ = transpose(trainZ);
testZ = transpose(testZ);
t_img = [trainZ testZ];
% import trained network from file
y_img = net(t_img);

4 Comments

Normally an image is either greyscale, in which case it is stored as 2D array Height x Width, or RGB in which case it is stored as a 3D array Height x Width x 3 whose 3rd dimension represen the colour channels (one Red, one Green and one Blue channel). Sometimes you can have a 4th Channel/band for transparency. So, what are your 21 channels?
It looks like your fusing loses more than the bands. It seems you've also fused the columns, leaving you with just one column. As such, there's not much left to display: just one column of an image.
The input image is a multispectral image containing 21 bands/channels. The fusion technique is designed to 2-d matrix data.
Well, as I said, in your result, not only have you fused the 21 bands, but you've also fused the 758 columns of the image, leaving you with just one column, so what would you display? Just that one column?

Sign in to comment.

Answers (0)

Asked:

on 12 Nov 2018

Commented:

on 12 Nov 2018

Community Treasure Hunt

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

Start Hunting!