Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any reverse operation to (image) gradient?

Suppose I have calculated gradient (of a grayscale image).

Gradient is a difference between neighboring pixels in X and Y directions.

Can I calculate image back, having this gradient information?

Can I filter gradient data somehow so that reverse operation give some reasonable results?

like image 579
Suzan Cioc Avatar asked Oct 20 '25 12:10

Suzan Cioc


1 Answers

Gradient is the difference between the color of two neighboring pixels. To get back the image you need one piece of information: the initial color of the boundary pixels.

Like in math, a derivation can be reversed by integration as far as a constant term is involved. Or, if you have d = a - b you can get back a only if you also know b.

Without the boundary values you can still recover the image but not at the same saturation & contrast. There will be a constant term missing from the entire image.

Example

Consider an image which has only 3 pixels: 42, 142, 100. The gradient will be 0, 100, -42 (computing it as the difference between the current pixel and the previous one). To get back the initial image we assume that the first pixel had been 0 and then do addition instead of subtraction: the recovered image will be 0, 100, (100-42). As you see, adding 42 to all of them will give us back the initial image.

like image 179
Mihai Maruseac Avatar answered Oct 23 '25 07:10

Mihai Maruseac



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!