Sign in to follow this  
Followers 0
Enormator

Primary Color Difference to Alpha

41 posts in this topic

It calculates for every pixel the difference between the pixel and the primary color. The more they are equal, the more alpha will rest. Just duplicate your layer, do my effect with a Primary color selected, maybe some fine tuning with Curves+ alpha channel and there you go affecting only this specially colored part of the image without need of feathering or anything because it's always a smooth gradient from layer to change to the original image layer.

Download here: EffectDLL.zip

Unzip it into your Effects directory in the Paint.NET folder.

It will be listed under Effects -> Color

example:

all9f9b7.png

1 to 2: Here i first chose the sky's color as primary with the Color Picker :ColorPicker: then I ran my effect.

2 to 3: After that I did some alpha fine tuning with Curves+ :Curves: . And the only color effect I added to the sky was increasing saturation and a little hue adjustment :HueSaturation: .

3 to 4: I put the original image as a layer under the modified one.

Link to where you get Curves+

code (Codelab):

int dr,dg,db;

void Render(Surface dst, Surface src, Rectangle rect)
{
   PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds);

   // Delete any of these lines you don't need
   Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();

   ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;

   ColorBgra CurrentPixel;
   for(int y = rect.Top; y < rect.Bottom; y++)
   {
       for (int x = rect.Left; x < rect.Right; x++)
       {
           if (selectionRegion.IsVisible(x, y))
           {
               CurrentPixel = src[x,y];
               dr = CurrentPixel.R - PrimaryColor.R;
               dg = CurrentPixel.G - PrimaryColor.G;
               db = CurrentPixel.B - PrimaryColor.B;
               if (dr < 0)
                dr=-dr;
               if (dg < 0)
                dg=-dg;
               if (db < 0)
                db=-db;
               CurrentPixel.A = (byte)(255-((dr+dg+db)/3));
               dst[x,y] = CurrentPixel;
           }
       }
   }
}

I'm currently searching for a good 16x16 png icon. Please tell me your ideas.

0

Share this post


Link to post
Share on other sites

Hmm...

WOOT! It's Curves+ alpha tweaking made simple, in some sort.

0

Share this post


Link to post
Share on other sites
thanks look nice tuts.....!!!

:?: What :?:

You keep saying nice tuts in plugin section?

0

Share this post


Link to post
Share on other sites

I'm a little confused...where would I want to use something like this? Enormator, could you explain the use for your plugin? :)

0

Share this post


Link to post
Share on other sites

You can use it always when you want to edit a picture. Use instead of a selection to get a better gradient without feathering.

You are the artist. I just wrote this plugin to use it for my self and because I'm a nice guy, I posted it here.

For creativity, ask god :P

0

Share this post


Link to post
Share on other sites
You can use it always when you want to edit a picture. Use instead of a selection to get a better gradient without feathering.

You are the artist. I just wrote this plugin to use it for my self and because I'm a nice guy, I posted it here.

For creativity, ask god :P

Thanks for answering Enormator. I'll give it a shot! :D

0

Share this post


Link to post
Share on other sites

It looks like it makes the image more vivid to me.

I likey!

[E to the d-it]Whoops, nevermind, I just read right after the pictures. My bad.

Asking god for creativity :oops:

0

Share this post


Link to post
Share on other sites

maybe he means toots

like hey toots hows your day ? lol

anyways nice plugin imma go try it out now

0

Share this post


Link to post
Share on other sites

Hi Enormator,

I really don't know how you managed to use the curves+ plugin to change your second picture into the third with bleached buildings against a blue sky!

Must be more than just fine adjustments with curves and little fine-tuning with hues!!!

0

Share this post


Link to post
Share on other sites

Please note, that all the effects were made on top layer. At the end I set the original layer under the changed layer to visible again.

0

Share this post


Link to post
Share on other sites

Hi Enormator!

I'll take the risk of revealing my ignorance by telling you that I don't know how to change the second picture to the third, nor the third to the fourth in the example that you gave!!

Wonder if you could explain the steps but if it's too bothersome, it's alright.

0

Share this post


Link to post
Share on other sites

No of course it's not to bothersome :)

It's always good, when people ask because I tend to explain in a quite ununderstandable way.

EDIT: I redid the explanation of the example in first post. Is it understandable now? Please ask because I can't see your thoughts. :wink:

0

Share this post


Link to post
Share on other sites

Lol! I'm sorry but the revised pictures tell me what I already can do - run your plugin on the first picture.

But in your example there is a third picture: How do I get that effect from your second picture using the curves+ plugin? From what I can see, just using your plugin alone cannot get me the same end-result that you obtained using curves+ and the hue adjustment plugins.

Tried running the curves + plugin but could never get to the third picture.

0

Share this post


Link to post
Share on other sites

Your curves+ must be set to alpha mode. Then your curve should look something like that

              ___
             /
            /
           /
___________/

Then when only the parts of the image which you want to modify are still visible, you can run any effect, in my case Hue/Saturation. But you could also do any other effect to the sky or the part of your image, which you selected.

0

Share this post


Link to post
Share on other sites

Nice idea. Thank you. I renamed the thread and the Effect. It's now in the Color Submenu.

I'm searching for a good 16x16 png icon for the Effect. If you have a good idea, pleas post here.

Redownload the dll to make the changes apply.

0

Share this post


Link to post
Share on other sites

Would you like it if this plugin would also support Hue difference mode? If there is at least one person who would find it useful, then I'll code it, otherwise not.

0

Share this post


Link to post
Share on other sites

Can you post the .dll file?

WinZip won't unzip anything anymore :|

Is there a free alternative to WinZip?

0

Share this post


Link to post
Share on other sites
Can you post the .dll file?

WinZip won't unzip anything anymore :|

Is there a free alternative to WinZip?

Windows has had built-in ZIP file support since XP. You don't need WinZip or any other program to open it... For other kinds of archives, though, try 7-zip.

0

Share this post


Link to post
Share on other sites
Windows has had built-in ZIP file support since XP.

I think it has ZIP support even in ME, but you have to install it seperately from the cd. However, programmes for ZIP can just be found via web search. 7 Zip is good, but you should try to get a stable version. There are only betas released for a while.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0