How to modify the function to input multi-channel images for CNN training in MATLAB 2017a?
9 views (last 30 days)
Show older comments
Hi,
I'm trying to train a Convolutional Neural Network with the newly released functions in MATLAB 2017a.
The input consists of two gray-scale images with resolution 100*100, so I stack them as a two-channel image, thus the dimension of the image is 100*100*2.
Next, I designed the architecture of input layer as
layers = [imageInputLayer([100 100 2])
...(omit the rest)]
However, only 1 (gray-scale image) and 3 (color image) are valid for the number of channels (the third parameter in [100 100 2]).
So my settings are invalid and the error is
Error using nnet.cnn.layer.ImageInputLayer>iCheckInputSize (line 238)
Expected input image size to be a 2 or 3 element vector. For a 3-element vector, the third element
must be 3 or 1.
I will appreciate that if anybody can help to modify the built-in function, so users can input a multi-channel image, such as a 2-channel image or a 200-channel image. I've tried but got stuck.
2 Comments
morteza ali ahmadi
on 17 Feb 2018
Edited: morteza ali ahmadi
on 17 Feb 2018
I also encountered this problem. Could you find a solution?
Answers (3)
Zhiyi TANG
on 27 Mar 2018
Edited: Zhiyi TANG
on 27 Mar 2018
1 Comment
hiba
on 6 Feb 2019
please con you explain more the sysnatxe of using imageInputLayer with 3 dimention image size [240* 240*155 ] thank yoiu
Muhammad Nabi
on 26 Mar 2018
I am having the same problem I have 4 2D feature images for the same label instance so my data set is [NxMx4] and I cant use a the CNN for it
2 Comments
Salma Ali
on 25 May 2018
Hi, I would like to use multi-input images with different sizes to CNN, is there any function in Matlab to do that? I appreciate any help. Thanks.
Xin Zhang
on 21 May 2018
Hi, i am trying to iunput 4 channels (RGB+Nir) to the RCNN. Thanks to your work, it seems that the input of 4 channels is possible using the 'imageInputLayer'. But I got another question of how to make the input argument'trainingData' of the function 'trainFasterRCNNObjectDetector'? It requires as 'Labeled ground truth images, specified as a table with two or more columns. The first column must contain paths and file names to grayscale or truecolor (RGB) images'. How can we make the argument 'trainingData' as 2 channels or 4 channels? Hope to get your reply soon. Best regards,
1 Comment
See Also
Categories
Find more on Image Data Workflows in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!