|
-
Dec 15th, 2015, 09:26 PM
#1
Thread Starter
Junior Member
Getting the intersection of two image files (as an image file)
Let's say I have 2 same-size images, a and b. Image a is all red pixels; b is all blue. Both images top halves are a slightly lighter color than their bottom halves.
Is there a method of getting an image that is the intersection of the two images? For example, the desired result (based on the example) would be a new image, of the same size as a and b, whose bottom half is transparent and whose top half is white with <255 alpha.
Another example would be, comparing an all-red image with an all-blue image (no lighter halves or anything) would yield a fully transparent new image.
EDIT: Please keep in mind that the red and blue images are simply examples. I'm looking for a method that works with any two images of the same dimensions.
Last edited by LogLady; Dec 16th, 2015 at 09:35 AM.
-
Dec 16th, 2015, 04:02 AM
#2
Re: Getting the intersection of two image files (as an image file)
If I understand you correctly, the color you want for the pixel at position (x, y) in the new image would be:
RGBA(255, 255, 255, 255 - (PicA.R + PicB.B) / 2)
So basically take the pixel (x,y) from both picA and picB. Add the red value of the picA image pixel and add the blue value of the picB image pixel and divide with 2 to get the average value. Subtract that from 255 to get the alpha level of the third picture.
-
Dec 16th, 2015, 09:31 AM
#3
Thread Starter
Junior Member
Re: Getting the intersection of two image files (as an image file)
Unfortunately, that would not achieve the desired result. In fact, close to the opposite: in the last example of intersecting a solid red image with a solid blue, the result would certainly not be transparent. In addition, how can I possibly get the intersection of two pixels by only dealing with thr R value of one and the B value of another? It seems to me that much of the pixel's information would be discarded.
-
Dec 16th, 2015, 11:01 AM
#4
Re: Getting the intersection of two image files (as an image file)
Hi LogLady,
Unfortunately you are going to have to explain a bit better what your desired result is. "Intersection" is a well-understood term for shapes but not for colors. The "rules" you have defined by example in post #1 seem to amount to:
1. Red + Blue = Transparent.
2. Slightly Lighter Red + Slightly Lighter Blue = White with alpha <255.
These rules aren't enough to tell us how to "intersect" other colours; for example, what color is Orange + "Slightly Lighter" Purple? And in which order do you want to add them?
Maybe you are thinking some well-known means of image blending such as drawing one image transparently over another, or combining the pixel colors additively (as for mixed lights) or subtractively (as for mixed paints). You might be looking for something like the Chroma Keying in this thread (I strongly recommend you look at it anyway). Or you might have something entirely different in mind; in that case, you could try to define a specific mixing formula like the example Joachim suggested.
If you are finding it hard to describe exactly what result you want, perhaps you could post some example images if possible with the intended mixing result.
BB
Last edited by boops boops; Dec 16th, 2015 at 11:09 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|