I have an image as follows:

checkered background example

The checkered pattern is not the transparency, it is impressed directly on the image, and runs across the whole graphic.

I would like to know if there is a way to remove the checkered background, extracting the original graphic without (much) damage. I suppose it is impossible, but maybe someone knows a trick.

  • 1
    Why you can download the voector image here. But yeah this has been explained before
    – joojaa
    Commented Nov 3, 2021 at 10:49
  • @joojaa this is just an example i made myself to show the problem. I have searched a lot but couldn't find useful links, do you have one?
    – Andrea
    Commented Nov 3, 2021 at 11:09
  • Yeah you can solve the mathematical belnding equation. You need to guess the alpha transparency though
    – joojaa
    Commented Nov 3, 2021 at 11:16
  • Google does not know your version of the image, except the instance in your GDSE question, but the one with no checkerboard is well known. Is yours the only one? For what actual purpose you expect to extract from here checkerboard removal tricks? Maybe testing the protection method? No method stands redrawing and a competent programmer beats this. I guess.
    – user82991
    Commented Nov 6, 2021 at 4:48
  • @user287001 I created the example above myself from a public domain clipart to make it less boring than just a random shape. I wanted to know this because I have a few personal images that have been saved this way and wanted to know if there was a way to remove the background. Also I was curious about the math involved in solving it.
    – Andrea
    Commented Nov 6, 2021 at 15:03

1 Answer 1


Alpha blending is:

Cout = α * CFG+(1-α) * CBG

Now there are two alphas on the image: a full transparency and the object transparency. The first order of business is to calculate the full transparency. Because we know the color and structure of the checker, we get a system of equations out of two pixels that have the same color.

C = α * CFGdark+(1-α) * CBGdark

C = α * CFGDLight+(1-α) * CBGLight

In these 2 equations there are 2 unknowns, so first let's solve for alpha. Since C is same in both equations we get:

α * CFGdark+(1-α) * CBGdark = α * CFGDLight+(1-α) * CBGLight

And then:

α * CFGdark+ CBGdark - α* CBGdark = α * CFGDLight+CBGLight -α * CBGLight

Collect by terms:

α * CFGdark - α* CBGdark - α * CFGDLight + α * CBGLight= CBGLight - CBGdark

break out alpha and divide

α = (CBGLight - CBGdark) / (CFGdark - CBGdark - CFGDLight + CBGLight)

Whew, now that we have calculated the alpha we can go use the first formula and solve it in terms of CBG:

Cout = α * CFG+(1-α) * CBG

collect by terms and divide:

CFG = -((1-α) * CBG - Cout)/ α

OK let's test this! Take the images:

bg.png and 0.5.png (click to zoom)

Where the second is a synthetic check with 50% opacity stroke on the background. We can use ImageMagick to do the calculation. Run the command

magick 05.png bg.png -fx "-((0.5)*u[1]-u[0])/0.5" out.png 

you get out.png

solid stroke on checkered background

Seems to work rather well. You can now do a difference alpha for an alpha mask.

Now the original image does not seem to be alpha blended. Maybe the mode is multiply or screen? Let us test those next.

Multiplication mode is:

Cout = CFG * CBG


CFG = Cout/CBG


Results in:

enter image description here

looks ok. But thats not it either. Maybe multiply with a blend?

Screen mode is:

Cout = 1 - (1 - CFG) * (1 - CBG)


CFG = (CBG - Cout) / (1 - CBG)

But that wouldnt be recoverable.

OK so not easy. But theres still stuff to go through. Maybe they have multiple alphas? What if the multiplication or blend was done color correctly and not naively like photoshop software tend to do? (Need to do actual work also sorry)

  • Interesting. However when you say "apply this to all pixels", you don't mention how to actually achieve that. Could you explain a little?
    – Billy Kerr
    Commented Nov 3, 2021 at 12:41
  • @BillyKerr depends heavily on what application you use. I mean in photoshop this is super tedious but for example in a comp app like say nuke, Fusion, Blender or say CAS (computer algebra system) like Mathematica no more work than writing the equation down
    – joojaa
    Commented Nov 3, 2021 at 12:44
  • Would it be possible using ImageMagick?
    – Billy Kerr
    Commented Nov 3, 2021 at 12:45
  • @BillyKerr maybe i must cogitate a bit how it deals with negative intermediate values.
    – joojaa
    Commented Nov 3, 2021 at 12:46
  • Cool, sorry I've got to just now, but if you can come up with anything that would be super amazing!!
    – Billy Kerr
    Commented Nov 3, 2021 at 12:47

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.