[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Transparent foreground extraction

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 19
Thread images: 3

File: composite.png (400KB, 1324x1096px) Image search: [Google]
composite.png
400KB, 1324x1096px
1. Have composite image.
2. Have background image.
3. Obtain foreground image.

How?
>>
File: background.png (124KB, 1324x1096px) Image search: [Google]
background.png
124KB, 1324x1096px
>>
File: foreground.png (314KB, 1324x1096px) Image search: [Google]
foreground.png
314KB, 1324x1096px
Wanted result.
>>
The inverse procedure (classic blending) is very simple:

r3 = r1 × α1 × (1 – α2) + r2 × α2 × (1 – α1),
g3 = g1 × α1 × (1 – α2) + g2 × α2 × (1 – α1),
b3 = b1 × b1 × (1 – α2) + b2 × α2 × (1 – α1),
α3 = α1 × α2, ← I’m not sure about this.
α3 = α1 × (1 – α2) + α2 × (1 – α1), ← Perhaps this?

...where:

rgbα1 = background pixel,
rgbα2 = foreground pixel,
rgbα3 = composite pixel.
>>
>>259582
I made up an incorrect formula there. The correct one, according to Wikipedia, is:

r3 × α3 = r1 × α1 × (1 – α2) + r2 × α2,
g3 × α3 = g1 × α1 × (1 – α2) + g2 × α2,
b3 × α3 = b1 × α1 × (1 – α2) + b2 × α2,
α3 = α1 × (1 – α2) + α2.

https://en.wikipedia.org/wiki/Alpha_compositing
>>
>>259579
Even more ideally, I’d like a procedure that not only reverses alpha blending but also guesses what kind of blending (other than alpha) it is by analysing the function that maps background pixels on composite pixels.
>>
Does this thread even have any followers?
>>
>>259644
I think this is way too complex for this board, anon
>>
>>259586
If you know the blending mode, its as simple as inverting the system of equations -- for the blending equations where this is possible. I think that's most of them. But in an LDR image, you will get a lot of precision loss due to blending, so blending/unblending will generally not give you back the original image, but a lower-quality version that will likely have banding, maybe clipping issues (dep. on blending mode)

If you don't know the blending mode... well, that's a bit tricky. A relatively robust approach might be to analyze the blending modes by their statistical properties, like median/mean/mode, maybe kurtosis in Lab/HSL/etc. For instance it should be pretty statistically obvious that multiplication (in a non-HDR colorspace) will always result in a darkening, that the various color-related blending modes (color dodge, vivid light etc) will result in the color being changed, that the "color" blending mode will not change the L channel, that "addition" will always result in an increase of the mean, etc etc.

I think to make this very robust across all the different blending modes commonly available though, you would have to throw in a bunch of characteristics. Like have a small database that defines how all the different blending modes are distinguished, so that you can distinguish even the more subtly different ones.

Also, if your foreground image is not sufficiently varied (e.g. a single blob of a single color or perhaps a linear gradient between two colors, dep. on the blending mode) I don't think this would give you a uniquely correct answer. I don't know if you necessarily would need to care, though, because the foreground image it would extract would still be "correct up to a constant", in a sense. It might not have the correct color or lightness, but it will give the correct result when used with the detected blending mode, and if you know what the foreground image is supposed to look like, just a simple recolor/color-invert/etc will fix it.
>>
>>259757
There is no other board. If it’s too complex for this board, it’s too complex for the Internet. Which can’t be true because I have seen more complex things dealt with. Or was that an illusion?

Look, Wikipedia requires a registered account, which limits the number of people that can post something there. And despite it, there’s an article about alpha compositing on Wikipedia. Meanwhile on 4chan, anyone can post. So why would it be too complex for 4chan??? Doesn’t 4chan have more users, and more types of users, than Wikipedia?
>>
>>259781
> Wikipedia requires a registered account

what are you smoking
>>
also, no, 4chan does not have more users than wikipedia, and most of the 4chan users are NEETs/weeabos/12-year-olds/etc.
>>
>>259782
Oh, right. I forgot that you can sign your posts using your IP number. I haven’t edited Wikipedia for years, so it was my right to forget.
>>
>>259783
>NEETs/weeabos/12-year-olds/etc
But why? 4chan is perfectly functional for any topic, not just anime. IMO forums such as Google+ are only a nuisance. Those forums don’t contribute any functionality that justifies smarter user base.
>>
Anyway... time to study this answer >>259780.

Which coincidentally came at the same time as my rant >>259781.

Thank you, anon.
>>
>>259789
*shrug*, it's a matter of social behaviour online. It might have to do with

- there being no reward for sharing your expertise -- not even fame, since you're anonymous
- there being no permanence to your contribution -- in a few minutes to a few months (dep. on board) it's gone
- there being no guarantees/peer-review/chain-of-trust on anything written, i.e. if I read an article in sth. like Phys. Rev. Letters or on some online forum where relatively well-known graphics programmers post with their name associated (or at the very least something like "pro-contributor, over 9000 posts!" next to their nick) I can somewhat trust the information they are giving. Obv. you should always question things, but it's good to know what ideas are at all worth pursuing and which are not.
- there being no real moderation/enforcement on on-topic-ness/other quality of discussion which helps to focus the discourse
- most boards on 4chan are not that topical -- e.g. /3/ is very general compared to e.g. the blender forum which will even have subforums dedicated to specific things, or the khronos forum which will have a subforum dedicated to e.g. OpenGL ES.
- the format is not all that good for in-depth discussions (no easy way to inline code/formulas like on stackoverflow, no good way to thread, vote or otherwise organize discussions...) -- it's all very basic, really

>>259795
np, I'll be sticking around for an hour or so probably, so do let me know if I can help with anything. I might also be here tomorrow, if I don't forget...
>>
>>259804
oh, also, 4chan doesn't exactly have a good name. Most people only know it for /b/, nothing else. So there's that.
>>
>>259804
It will take me more than one hour to assimilate what you wrote there. Your answer is filled with enough many ideas that I haven’t thought about before that this thread will probably die by the time my brain needs another boost from someone more knowledgeable.

Thanks again.
>>
>>259822
Threads on /gd/ tend to stick around for weeks.
Thread posts: 19
Thread images: 3


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.