# How to retrieve RGBA mask used to transform image1 into image2

Let image1 be:

And RGBA mask be:

(45, 78, 251, 102)

Apply mask on top of image1 to get image2:

Now I need to do the reverse thing, given image1 and image2, is there a formula or an algorithm (there has to be right?) to find the mask?

Thanks in advance, first post in here I might lack vocabulary I'm sorry about that, my tags might be completely off.

EDIT: i program in Java. I get image2 by drawing image1 on some Windows native frame using Graphics#drawImage and then drawing the filter made of (45, 78, 251, 102) RGBA pixels on top of that image using the same function.

• What does "mask" mean in this context? That looks more like a multiplication than any kind of "masking". Nov 1 '20 at 22:10
• By mask I meant an image filled with (45, 78, 251, 102) RGBA pixels. Nov 1 '20 at 23:16
• OK, so you have an image with that color. But what do you do with it? The term "mask" is usually meant to apply to an image that obscures part of another image. Are you talking about blending with the image? And if so, is it a weighted blend based on the alpha? My question is what exactly is the mathematical function you're talking about here. Because "mask" isn't a function that I'm aware of. Nov 2 '20 at 0:33
• I'm just looking for the RGBA color (this is what I meant by mask) I need to apply on top of my first image in order to obtain the second image. Nov 2 '20 at 1:53
• And I'm looking for the math function you used when applying that color to the source image to get the result. The word "mask" is telling me precisely nothing. Is this a multiplication operation? What is the mathematical equation being performed per-pixel to get the result? Please put that in your question. Nov 2 '20 at 1:57