<p>Let <code>image1</code> be:</p>
<p><a href="https://i.sstatic.net/Yhc6R.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Yhc6R.png" alt="enter image description here" /></a></p>
<p>And RGBA <code>mask</code> be:</p>
<p>(45, 78, 251, 102)</p>
<p>Apply <code>mask</code> on top of <code>image1</code> to get <code>image2</code>:</p>
<p><a href="https://i.sstatic.net/VIOvh.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/VIOvh.png" alt="enter image description here" /></a></p>
<p>Now I need to do the reverse thing, given <code>image1</code> and <code>image2</code>, is there a formula or an algorithm (there has to be right?) to find the <code>mask</code>?</p>
<p>Thanks in advance, first post in here I might lack vocabulary I'm sorry about that, my tags might be completely off.</p>
<p>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.</p>

CC BY-SA 4.0
2020-11-01T22:10:56.317Z
What does "mask" mean in this context? That looks more like a multiplication than any kind of "masking".
Nicol Bolas
CC BY-SA 4.0
2020-11-01T23:16:47.607Z
By mask I meant an image filled with (45, 78, 251, 102) RGBA pixels.
dylanbatio
CC BY-SA 4.0
2020-11-02T00:33:44.803Z
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.
Nicol Bolas
CC BY-SA 4.0
2020-11-02T01:53:55.747Z
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.
dylanbatio
CC BY-SA 4.0
2020-11-02T01:57:32.063Z
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.
Nicol Bolas
CC BY-SA 4.0
2020-11-02T14:19:33.587Z
What does "printing" mean in this context? You don't "print" images to the screen. Please be specific as to the exact operation you're performing.
Nicol Bolas
CC BY-SA 4.0
2020-11-03T11:03:39.567Z
This sounds a little like  https://computergraphics.stackexchange.com/questions/9759/given-a-background-image-b-and-a-composie-image-of-a-over-b-can-we-somehow-reco/9795#9795
Simon F
<filtering><masking><java>
How to retrieve RGBA mask used to transform image1 into image2
dylanbatio
# How to retrieve RGBA mask used to transform image1 into image2

(Asked by: username_0 on 2020-11-01)

Let `image1` be:

[![enter image description here](https://i.sstatic.net/Yhc6R.png)](https://i.sstatic.net/Yhc6R.png)

And RGBA `mask` be:

(45, 78, 251, 102)

Apply `mask` on top of `image1` to get `image2`:

[![enter image description here](https://i.sstatic.net/VIOvh.png)](https://i.sstatic.net/VIOvh.png)

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.

**Tags:** filtering, masking, java

> **Comments:**
> **username_1**: What does "mask" mean in this context? That looks more like a multiplication than any kind of "masking".  
> **username_0**: By mask I meant an image filled with (45, 78, 251, 102) RGBA pixels.  
> **username_1**: 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.  
> **username_0**: 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.  
> **username_1**: 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.  
> **username_1**: What does "printing" mean in this context? You don't "print" images to the screen. Please be specific as to the exact operation you're performing.  
> **username_2**: This sounds a little like  https://computergraphics.stackexchange.com/questions/9759/given-a-background-image-b-and-a-composie-image-of-a-over-b-can-we-somehow-reco/9795#9795  

---

## 0 answers

