Vhonowslend / StreamFX-Public

StreamFX is a plugin for OBS® Studio which adds many new effects, filters, sources, transitions and encoders! Be it 3D Transform, Blur, complex Masking, or even custom shaders, you'll find it all here.
https://streamfx.vhonowslend.com
GNU General Public License v2.0
3.94k stars 3.03k forks source link

image thresholding/binarization #147

Closed bnfd closed 4 years ago

bnfd commented 4 years ago

Can StreamFX help with this? https://obsproject.com/forum/threads/increase-gamma-saturation-of-colors.118691/post-446780

Xaymar commented 4 years ago

There is a Color Grading filter added by StreamFX, so it might be able to help you with that. Using it might feel familiar if you've used color grading in Adobe Premiere Pro or BlackMagicDesign DaVinci Resolve.

bnfd commented 4 years ago

Thanks for the reply. Did you refer to thresholding or gamma/saturation?

Xaymar commented 4 years ago

Gamma and Saturation. For making something either color a or color b, you might have to toy around with luma detection and use the tint options to your advantage.

Xaymar commented 4 years ago

The current Shader implementation in the latest beta also allows you to do this, but you will have to learn how to write shaders first. HLSL isn't very difficult to learn, and is usually the better option to do unusual effects.

skeletonbow commented 4 years ago

I played around with using OBS filters to try to do that last night based on the image in the linked forum thread. I was able to isolate the whiteboard and make it bright, and then was attempting to separately isolate the foreground whiteboard content in black, but the problem I was encountering is that due to horrible lighting in the source image, the dark shade of the text on the board is too close to the background color at further away places in the image, so anything I tried to do to highlight the text on the board also highlighted the dark edges. I played around with saturation, gamma, luma and other controls, and was able to isolate the current text on the board as it is in a spot where the background is highlighted, but I ended up also having a big black donut around it, which would fail as a generic effect for arbitrary text across the whiteboard.

It might be possible to do better enhancement using a custom shader for this, but... honestly, the solution I would go with is "buy better lights to light up the whiteboard better". The easiest enhancement effect to create is to not work around environment problems with filters, but to fix the environment to give a better captured visual to begin with. This of course only works for content not yet produced.

If there is content already recorded that needs to be fixed, the best way to do it is probably with post-production in a video compositing tool rather than inside OBS.

Still, I am curious about solving these types of problems programmatically too, so it would be fun challenge to try to make a shader that can do it. I might play around and take a stab at it, but I'm still quite a newbie at this so don't get any hopes up hehe.

Xaymar commented 4 years ago

Assuming that this is technically solved since you can do this with existing tools. If you need help implementing it, consider joining the official discord for the plugin.

skeletonbow commented 4 years ago

I made a simple binarization shader I can share, although it's not using any advanced algorithms or anything, just calculating luma and everything below a user configurable threshold goes black, everything above goes white. I plan to investigate more fancy methods in the future.