This sample image:


is warped on the left side.

I don't want to dewarp, but just to remove shadow gradient (caused by book's spine). I guess gradient can be calculated from upper part of the image and that information can be used for reconstruction.

First I thought to apply some layer transformation in Photoshop. I took upper part with clear gradient and scaled it vertically to cover whole image in new layer. Then I did layer difference:


but while upper part is acceptably reconstructed, colored part is not.

Does anyone have an idea how to approach this in Photoshop, or Python/SciPy/OpenCV, or Matlab?

  • 2
    $\begingroup$ try applying a saturation filter with same mask in photoshop $\endgroup$ Commented Mar 6, 2013 at 9:12
  • 1
    $\begingroup$ Hi geometrikal ;) Can you post it as answer and paste result screenshot? Thanks $\endgroup$
    – zetah
    Commented Mar 6, 2013 at 10:55

1 Answer 1


The simplest approach would be to divide the gradient rather than subtract it. Here's what the result looks like:

Gradient Removal

  • $\begingroup$ This is really cool! How did you extract the gradient? $\endgroup$
    – Phonon
    Commented Mar 9, 2013 at 5:42
  • $\begingroup$ Oh, same way as the OP did (I think). Took the top section and scaled it vertically. $\endgroup$
    – datageist
    Commented Mar 9, 2013 at 5:44
  • $\begingroup$ Cool, I suspected so. = ) $\endgroup$
    – Phonon
    Commented Mar 9, 2013 at 5:47
  • $\begingroup$ Thanks, it works great. From the layer operation blend naming, I assume you use Gimp ;) $\endgroup$
    – zetah
    Commented Mar 9, 2013 at 11:57
  • $\begingroup$ I actually used PS (CS6), but was thinking more about math than blend modes :) $\endgroup$
    – datageist
    Commented Mar 9, 2013 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.