Hello, I write a neural network that recognizes images. There are 2 questions!

So, 1: What is the best way to specify a pixel by a number (PIL gives the color according to RGB (255,255,255)), but I would like it either in brightness (from 0 to 255) or in some other way!

And question 2: Suppose we were able to display images in a list of values ​​(numbers), but here the next problem is that if we have an image of 500x500 pixels, then the length of the list (500 * 500) is 250,000 pickels !!! If this is applied to the input of the neural network, then it will plow for ages! It is necessary to somehow “compress the image” while preserving the main features, the DFT (discrete Fourier transform) does not help, because the length of the input and output list is the same! And we need to reduce the length!

Thanks for attention! I hope to help me!))

  • It seems to me that everything will depend heavily on a specific task. You just have to try. - Qwertiy ♦
  • If you knew what to do, and how!) - Nazar

1 answer 1

Hello,
1) use a gray palette. I advise you to carry out the transformation according to the histogram analysis algorithm.
2) To do this, you need to divide the image into blocks whose size is k times smaller than the size of what you are looking for. (k depends on what you are looking for). And take some function from the block, there are many such operators, it also depends on what you are looking for), you get a smaller matrix.
The impossibility of improving 1) is that you want from 256 ^ 3 -> 256 values, so there will be a loss of information.
A 2) this is a known method. You can read about it in Habré.

  • Do you propose to convert an image into a gray palette, and then reduce the number of pixels by converting according to the histogram analysis algorithm? - Nazar
  • I understand that for such large images without SNA (Convolutional Neural Networks) can not do. :) - Nazar