<p>I am working with four grayscale images of float32 data type to perform regression using Keras. Three images are stacked using <code>np.dstack</code> to form a RGB data-set. The last grayscale image is used as label. The grayscale images contains different variations, including [0 , 790.65], [ 150.87 , 260.45], [ -2.74174 , 2.4126 ], [-32.927 , 69.333].</p>
<p>If I convert the images to unit8, the maximum values for the first and second image will be 255 and the decimal values for all images will be lost.  I am having difficulty and struggling to find the solution for using the image in the original data type (float32) when I try to use <code>ImageDataGenerator</code> and <code>flow_from_directory</code>. Can anyone suggest way for that?</p>

CC BY-SA 4.0
2021-04-07T17:16:04.410Z
Data size is too low. And the loss of information of casting from float to int won't be that high.
Abhishek Verma
CC BY-SA 4.0
2021-04-07T22:58:02.147Z
Your images should be normalized. You can choose any range (e.g. [-1, 0] or [0, 1]), but the main condition is that it must represent the intensities of the pixels and has to  be able to be scaled back to the original range [0, 255]. btw `matplolib` can plot normalized images in range [0, 1]
Aray Karjauv
<neural-networks><convolutional-neural-networks><tensorflow><python><regression>
Is it possible to use RGB image with decimal values when feeding training data to CNN?
Sam
# Is it possible to use RGB image with decimal values when feeding training data to CNN?

(Asked by: username_0 on 2021-04-07)

I am working with four grayscale images of float32 data type to perform regression using Keras. Three images are stacked using `np.dstack` to form a RGB data-set. The last grayscale image is used as label. The grayscale images contains different variations, including [0 , 790.65], [ 150.87 , 260.45], [ -2.74174 , 2.4126 ], [-32.927 , 69.333].

If I convert the images to unit8, the maximum values for the first and second image will be 255 and the decimal values for all images will be lost. I am having difficulty and struggling to find the solution for using the image in the original data type (float32) when I try to use `ImageDataGenerator` and `flow_from_directory`. Can anyone suggest way for that?

**Tags:** neural-networks, convolutional-neural-networks, tensorflow, python, regression

> **Comments:**
> **username_1**: Data size is too low. And the loss of information of casting from float to int won't be that high.  
> **username_2**: Your images should be normalized. You can choose any range (e.g. [-1, 0] or [0, 1]), but the main condition is that it must represent the intensities of the pixels and has to  be able to be scaled back to the original range [0, 255]. btw `matplolib` can plot normalized images in range [0, 1]  

---

## 0 answers

