Forum

Customizable Image Filters

Hey good people of vvvv,

i am a beginner at vvvv and fairly new to programming in general so please forgive my ignorance. I am currently trying to make custom image filters (making all pixels with a red value above 200/255 transparent for example). A fairly simple task it seems, but I find myself lost with so many nodes to choose from. I have looked into OpenCV and Bitmaps but can’t quite make sense of it all. Any help as to what would be the best approach are very much appreciated.

Thanks in advance.

Hi @Kel_Thuzad, I made this patch to achieve what you described using VL.OpenCV, I tried adding comments to explain what is going on, let me know if you have questions.

Made with gamma 2020.1

RedValTransparentFilter.vl (38.7 KB)

2 Likes

Thank you so much @ravazquez :-)
this is exactly what I was looking for.

1 Like

I have used the OpenCV nodes for a few weeks but I now got to the point where I need a more versatile system. I would like to process images by extracting every pixel’s values and reinserting them after having changed them. I have already achieved this using 2 ForEach loops and bitmaps but can’t find a way to display a BitmapImage in a renderer (maybe there is a way?).
Alternatively maybe there is a way to use OpenCV (@ravazquez) to achieve the same thing? Using Pipet(GetPixelsAsFloats) and putting them back into a mat/reversing the process?

Thanks in advance.

@Kel_Thuzad if its a simple value to value mapping you want then I think a lookup table is enough. In gamma’s help browser search for LUT (lookup table), there is a help patch demonstrating the node. You can basically create a table where you describe for each possible pixel value what the resulting color should be.

I would not recommend doing this via Pipet since you will need to sample every pixel and at high resolutions it will get heavy, specially since VL.OpenCV is running exclusively on the CPU. Such an approach is best handled on the GPU directly using shaders for example, and this is not yet supported in gamma.

Hope that helps.

Regarding BitmapImage I believe there should be a set of ToImage/FromImage nodes for it that allow you to convert it to the type of Image you need it to be.

@ravazquez thank you for getting back to me so soon. The LUT seems to be fairly close to what I want to achieve. However it doesn’t allow me to use the pixel coordinates to influence the color values.
I was kinda looking for the classic forEach loop within a forEach loop, to get every pixel and reinsert it into the same row & column. I have tried this approach with bitmaps and MutableArrays so far. Both seem to work but give me technical difficulties.
The MutableArray method works for about 1 second then crashes the Renderer and sometimes even Gamma itself. The bitmap method seems not to crash but I cannot find a single node that uses a bitmap or a BitmapImage as an input to transform it into a usable image (Maybe I’m just overseeing something?).
Though I am working with gamma I found this pixelshading tutorial about vvvv beta that seems to be describing what I want, but it is beyond my understanding (https://vvvv.org/documentation/tutorial-of-effects-and-shaders).