# Image filters

 10 October 2009 Do3d New Member portfolio Amit A 2 Z Mumbai, India Image filters Hey I am looking for more information about the algorithm used in the standard imaging filters such as multiply , burn, dodge etc... Can anyonme suggest me some programming, math or books on this topic. share quote
 10 October 2009 tmr232 Frequenter   portfolio Tamir Bahar student Maor, Israel The basic blend modes (multiply, burn, dodge, lighten, darken etc.) are all pretty simple local operations on two layers of color. So basically, all you need is a blend function, and to use it on all pixels in your resulting image. Basic C code with all the blend modes can be found here: LINK If you have a basic understanding of C, this should really be enough. Feel free to ask if you need further guidance. Tamir. __________________ Ha ha! Programming again. share quote
 10 October 2009 Do3d New Member portfolio Amit A 2 Z Mumbai, India Cool Thanks. Thats what I was looking for. share quote
 10 October 2009 ndeboar Expert   portfolio CGConnect Member Nick Deboar Lighting TD AU multiply = a x b darken = min (a,b) lighting = max (a,b) linear dodge = a + b share quote
 10 October 2009 wobagi New Member portfolio WoBagi Warszawa, Poland PDF reference describes this. http://www.adobe.com/devnet/pdf/pdf_reference.html share quote
 10 October 2009 ScEngMan New Member portfolio Diego Castano SceneEngine Burnaby, Canada When blending two layers with a Blending Mode and Opacity, there are two steps: 1. Generate the Blending Layer using a Blending Mode (Multiply, Divide, etc). This is done by mixing the Background Layer with the Foreground Layer using a Blending function. 2. Combine the Blending Layer with the Background Layer using a Combine function (most usually MixOpacity). I implemented Blending functions and Combine functions for colors defined by 4 unsigned chars from many resources (including the links above), and I created a single header -mix.h - that can be used anywhere. Here is an example of how to combine two colors to get the same result as PhotoShop with two layers with alpha, a Multiply blending mode and an Opacity of 50.0. `````` #include "mix.h" unsigned char bg[4] = { 180, 70, 70, 255 }; unsigned char fg[4] = { 80, 70, 175, 128 }; unsigned char opacity = 128; (50%) unsigned char dest[4] = { 0, 0, 0, 0 }; Multiply( dest, bg, fg ); // Blend bg and fg -> dest MixOpacity( dest, bg, dest, opacity ); // Combint bg and dest -> dest`````` All this stuff is implemented by the Texture Painting tool for CrackArt, so you can download the full source code and check it out. share quote
 10 October 2009 MDuffy Trained Monkey   portfolio Michael Duffy Prog. Dept. Manager McKinney, USA I know others have already answered the question, but I've always found the following site to be a good description of each blending mode: http://www.pegtop.net/delphi/articles/blendmodes/ Cheers, Michael share quote
 11 November 2009 mtartist Hobbyist Edward Malta I have a question on the related subject. Given two RGBA colours c1 = {r1, g1, b1, a1} (top) and c2 = {r2, g2, b2, a2} (bottom), I want to find the resulting colour cr = {r, g, b, a} when both colours are composited using the 'Normal' mode algorithm. The algorithms I managed to find, seem to assume that the bottom colour has an opacity of 255 (fully opaque), but what if it doesn't? After some experimentation, I figured that the resultant opacity can be calculated by: a = (255 - a2) / 255 * a1 + a2; Could anyone please tell me how I can find the other three colour components? Thank you share quote
 11 November 2009 wobagi New Member portfolio WoBagi Warszawa, Poland From what I find in PDF spec: ``````a_r * C_r = ((1-a_1) * a_2 * C_2) + ((1-a_2) * a_1 * C_1) + (a_2 * a_1 * B(C_2, C_1))`````` where a_? - alpha for resulting (r), top (1) and bottom (2) layers C_? - color, accordingly B() - blend function in this case (normal mode): ``B(C_2, C_1) = C_1`` , so ``````a_r * C_r = ((1-a_1)*a_2*C_2) + ((1-a_2)*a_1*C_1) + (a_2*a_1*C_1) = ((1-a_1)*a_2*C_2) + a_1*C_1 `````` share quote
 11 November 2009 mtartist Hobbyist Edward Malta Thank you wobagi, it worked fine. Also, after having a look at that reference PDF, it seems to be very useful. share quote
 11 November 2009 CGTalk Moderation Expert Thread automatically closed This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum. __________________ CGTalk Policy/Legalities Note that as CGTalk Members, you agree to the terms and conditions of using this website. share quote

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off CGSociety Society of Digital Artists www.cgsociety.org Powered by vBulletinCopyright ©2000 - 2006, Jelsoft Enterprises Ltd.