Sign in to follow this  
Followers 0
MichaelVinther

Increase Local Contrast effect plugin

42 posts in this topic

Increase local contrast can improve badly lit photos. It can also give a dramatic effect to otherwise dull pictures. Decreasing the filter size will increase the local contrast and color saturation. Note that the filter tend to amplyfy any noise in the picture (especially with small filter and high contrast settings) so it can be a good idea to apply noise reduction before the operation.
I think that this kind of filter is sometimes refered to as a retinex filter. The effect is also similar to what you can achieve with HDR software.

Example:
KievContrastBefore.jpgKievContrastAfter.jpg

Download version 1.2.0.0 (2012-04-06):

MODERATORS NOTE:  This effect is incompatible with Paint.NET 4.0x
http://meesoft.com/P...calContrast.zip
Unzip the file in the Paint.NET\Effects folder.

You can access the feature from the Effects | Photo menu.

Edited by Ego Eram Reputo
0

Share this post


Link to post
Share on other sites

Not to be too picky but this would be great with a "review" button so that I could check back with the original pic while using it. Great plugin, at first I thought it was gonna be like the "Local Contrast Enhancement" plugin but it's not. It's seems like this is gonna help a lot with my current project of replicating HDR images with Paint.net

0

Share this post


Link to post
Share on other sites

Maybe it is best you put the dll in a zip file. Some firewalls don’t allow people to download dll’s.

EDIT: Plug-in works good. :D

0

Share this post


Link to post
Share on other sites
Maybe it is best you put the dll in a zip file. Some firewalls don’t allow people to download dll’s.

EDIT: Plug-in works good. :D

Leif is correct. Please zip the file. (and use .ZIP, please, not .7Z or .RAR or anything...)

0

Share this post


Link to post
Share on other sites

Ok, I have added a ZIP download.

This is my very first PDN plugin (and one of my first C# projects...) - just took an afternoon to do it. I thought about making a Show original button to make it easy to compare but I didn't know how. I will try to find out..

If you see any crashes please let me know if it happens with a special kind of image or if you have any other idea what triggered it.

0

Share this post


Link to post
Share on other sites
So we try again - this time without using Parallel Extensions (and without multicore optimization).

You do realize that Paint.NET's effect renderer is already multithreaded? Your OnRender() method is already multithreaded, unless you specifically tell Paint.NET to work in single threaded mode.

0

Share this post


Link to post
Share on other sites

Also, you should really use IndirectUI instead of implementing your own dialog. You've just got two sliders, there's really no reason to implement all of your own data binding and layout.

Derive from PropertyBasedEffect instead, and go from there.

0

Share this post


Link to post
Share on other sites

Ok, thanks for the hint about the dialog. The example plugin I based mine on just had an empty form so I assumed that I had to make the GUI from scratch.

About multithreading, it is not that simple. My algorithm is a multi-pass IIR filter so I cannot just compute any pixel independant of the others. Actually everything is computed the first time Render() is called with a new parameter token in a lock() { } section so any following calls (in the same thread or others) will just return pixels. This is why the progress bar appears to stop for a long time at 0%.

0

Share this post


Link to post
Share on other sites

leave it to me to somehow mess something up:

Error Report:

  • File: C:\Program Files\Paint.NET\Effects\IncreaseLocalContrast.dll
    Effect Name: MeeSoft.Paint.Net.Plugins.IncreaseLocalContrast.EffectPlugin
    Full error message: PaintDotNet.WorkerThreadException: Worker thread threw an exception ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
    File name: 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    at MeeSoft.ImageProcessing.PlanarBitmap.New(Int32 planeCount, Double gamma)
    at MeeSoft.ImageProcessing.PlanarBitmap.New(Int32 width, Int32 height, Int32 planeCount, Double gamma)
    at MeeSoft.ImageProcessing.PlanarBitmap.Assign(Bitmap source)
    at MeeSoft.Paint.Net.Plugins.IncreaseLocalContrast.EffectOperation.CheckParams(EffectPluginConfigToken param, Bitmap srcBitmap)
    at MeeSoft.Paint.Net.Plugins.IncreaseLocalContrast.EffectPlugin.Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, Int32 startIndex, Int32 length)
    at PaintDotNet.Effects.BackgroundEffectRenderer.ThreadFunction()
    WRN: Assembly binding logging is turned OFF.
    To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
    Note: There is some performance penalty associated with assembly bind failure logging.
    To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
    --- End of inner exception stack trace ---
    at PaintDotNet.Effects.BackgroundEffectRenderer.Join()
    at PaintDotNet.Effects.BackgroundEffectRenderer.Start()
    at PaintDotNet.Menus.EffectMenuBase.<>c__DisplayClassb.b__8(Object sender, EventArgs e)

0

Share this post


Link to post
Share on other sites

It looks like this plugin requires .NET version 3.5, which you either don't have or your installation is not right.

I could be wrong -- I just gathered that from a quick glance at the crash log.

0

Share this post


Link to post
Share on other sites
leave it to me to somehow mess something up:

You need to install .NET Framework 3.5 SP1. I'll add this to the plugin details at the top.

Edit: Just noticed he already spelled this out. But, my edit makes it more obvious :)

0

Share this post


Link to post
Share on other sites
Ok, thanks for the hint about the dialog. The example plugin I based mine on just had an empty form so I assumed that I had to make the GUI from scratch.

About multithreading, it is not that simple. My algorithm is a multi-pass IIR filter so I cannot just compute any pixel independant of the others. Actually everything is computed the first time Render() is called with a new parameter token in a lock() { } section so any following calls (in the same thread or others) will just return pixels. This is why the progress bar appears to stop for a long time at 0%.

Hi Michael,

This could be worth a read: Buffered Graphics

0

Share this post


Link to post
Share on other sites

Looks like alternative to Shadow/highlight recovery...

I thought about making a Show original button to make it easy to compare but I didn't know how. I will try to find out..
You can check for exampe here.

In my version the review button is bound to a check box that triggers Identity() pixel op when checked.

If you decide to go for IndirectUI then you could simply add a check box "Show original" where checked state would return original.

Here is the relevant part of my code:

Hidden Content:
...
private UnaryPixelOps.Identity Nop = new UnaryPixelOps.Identity(); // this op returns original image when "Review" button is pressed

       public override unsafe void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length)
       {
           ...
           bool check = token.checkBox2; // that's linked to Review button pressed state
           ...
           Surface dst = dstArgs.Surface;
           Surface src = srcArgs.Surface;

           if (check == false) // "REVIEW" BUTTON IS PRESSED -> ORIGINAL IMAGE IS SHOWN
           {
               Nop.Apply(dst, src, rois, startIndex, length);
           }

           else  // "REVIEW" BUTTON IS NOT PRESSED -> EFFECT IS RUNNING
           {
           ...

BTW, are you the guy who created Image Analyzer?

I have learnt a lot of things whith that program, really appreciate! :)

0

Share this post


Link to post
Share on other sites

Ok, thanks for all of your suggestions. I have released a new version of the plugin (same download link as above).

News:


  • [*:3466sfj6] There is now a button called "Original" which you can hold to show the source image.
    [*:3466sfj6] The menu item appears in the correct menu also for non-english versions of PDN
    [*:3466sfj6] The filter size default was changed to 30 for a more distinct result

Also, you should really use IndirectUI instead of implementing your own dialog. You've just got two sliders, there's really no reason to implement all of your own data binding and layout.

Derive from PropertyBasedEffect instead, and go from there.

I tried this, but the GUI did not behave as nice as I can make it with my own dialog. Have a look at my comment to this topic in the development forum.

BTW, are you the guy who created Image Analyzer?

Yes, I am. The Increase Local Contrast effect also exists in IA but with a few more options. I have considered making more of the features from IA available as plugins for PDN.

0

Share this post


Link to post
Share on other sites
Could anyone please write the correct string for the Photo submenu? I mean the localizeable version.

It's already there in the SubmenuNames static class. He just needs to use it.

0

Share this post


Link to post
Share on other sites

I'm afraid there's a rendering bug. I used it on a 1280x8xx image and aftwerwards it looked like it was splited in parts and put together in a wrong way. Apparently it happens when your zoom is set to 100%.

The bug was reproduceable, but sometimes you need to look closely.

0

Share this post


Link to post
Share on other sites

Ok, I fixed the rendering problem. It happened only when the zoom was 100% for some reason, so I didn't notice it before.

0

Share this post


Link to post
Share on other sites
Ok, I fixed the rendering problem. It happened only when the zoom was 100% for some reason, so I didn't notice it before.

Thanks. I'd also ask you to add the publishing date of the current version to your first post, like 2009/03/23, instead of just a version number like 1.0.1.1. It's pretty hard to say if something has changed if it's like 1.0.1.0 to 1.0.1.1. Especially imagine someone has holidays, comes back and cannot tell wether something has changed or not. If you see that the current version was published on, say 09/03/30, you won't have to guess.

0

Share this post


Link to post
Share on other sites

Thanks for the plugin - works very nicely. Appreciate the presence of a button to see the original photo state but is there a way to resume applying the plugin effect after reverting to the original state?

0

Share this post


Link to post
Share on other sites

Oops! Apologies but I've re-read the first post again and realize that the original photo state stays on only when the mouse is held down. Thanks for the plugnin.

0

Share this post


Link to post
Share on other sites

Great plugin, I'll try it out as soon as I can. Looks very promising for spicing up pictures.

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