Answer the question
In order to leave comments, you need to log in
How to calculate the function f(x,y) representing it from a 2-dimensional matrix?
Math problem.
There is a black-white BMP image written with a binary matrix (0,1) or a matrix of bytes (0...255).
How to calculate the function f (x, y) from this matrix, which returns all values of this matrix in the same range?
Something like f(x,y) = (15 + 3.4*sin(x) + 15.09f*y^2 + ...) > 0; , where by removing the last elements of the formula we get a less accurate result compared to the original image.
The point is to calculate the original image in the program using this function in order not to store the entire image and reduce the size of the program. So to speak, replace memory with calculations.
I am looking for an algorithm for calculating such a function in C (you can use C# or Lua), or better, an online service where you can upload an image and get a formula that describes it with a given accuracy.
Yes, there is another option to store as PNG, not as an array of pixels, but for one image, the decoder code will certainly be commensurate with the size of the original image.
Answer the question
In order to leave comments, you need to log in
In the universal case, oddly enough, at the moment neural networks are such a function, there was an article on Habré about researchers experimenting with video restoration using a meager function (a neural network, and a few kilobytes were obtained there for all videos).
https://habr.com/post/372337/
But the task of obtaining this function is usually solved by learning algorithms when there is a lot of data (in your case, these are pixels, an unusual option for input coordinates for output color) and this is terribly demanding in terms of calculations ( while there are no pieces of iron for this in the public domain, Google, for example, released it for itself), they use video cards, or rather clusters of them.
This is not the only way, there is more stupidly in the forehead, enumeration of the function itself (the function is literally assembled by enumeration of operators, water variables and constants and the original and calculated data array is compared, the constants are selected using optimization algorithms), I remember I saw paid packages for this, according to resources, this is an even more costly process, but the decision on the mind turns out to be clearer, without the redundancy that is inherent in neural networks.
You can try to find a function approximately by assuming its order in advance - using the gradient descent method. But this will be a "blurry" approximation.
Imagine you have clear zeros and ones in the original image, diagonally:
0 1
1 0
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question