I have a grayscale image input with shape [4, 1, 32, 32]
.
I want to make the second parameter to 3, which will have three channels and shape becomes [4, 3, 32, 32]
.
Are there any methods that can achieve this using numpy?
Thank you so much for your help in advance.
Asked
Active
Viewed 965 times
0

thom
- 13
- 6
-
And how do you want to fill the new channels? – Mr. T Jan 23 '21 at 10:42
-
By multiplying defined values like, [0.2989, 0.5870, 0.1140] to each RGB channels?.. Not sure about it. – thom Jan 23 '21 at 10:47
-
To add dimensions is easy: https://stackoverflow.com/q/40119743/8881141 However, the grayscale array has not implicit information about R, G, and B color channels, as you might assume. – Mr. T Jan 23 '21 at 10:52
-
*"I want to make the second parameter to 3"*, that would be called image colorization, and it is not a trivial task. – Ivan Jan 23 '21 at 11:24
-
Think it like 'you will have missing information' if you reshape it from 1 to 3 in second dimension. Always check the multiplication of the dimensions, if they are not matching there could be two scenarios. If the new multiplication higher than old, you will have missing information, otherwise you will ignore the information that you have. Specifically for this case, you should first decide how you would like to change grey scale to RGB. In gray scale image there is no information about RGB colors. – aykcandem Jan 23 '21 at 11:36
-
Does this answer your question? [convert a grayscale image to a 3-channel image](https://stackoverflow.com/questions/40119743/convert-a-grayscale-image-to-a-3-channel-image) – armamut Jan 23 '21 at 14:59