Jump to content


Photo

Increase Local Contrast effect plugin


  • Please log in to reply
40 replies to this topic

#1 MichaelVinther

MichaelVinther
  • Members
  • 23 posts
  • LocationDenmark
  • Reputation:0

Posted 16 March 2009 - 05:43 PM

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:
Posted Image Posted Image

Download version 1.2.0.0 (2012-04-06):
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 MichaelVinther, 11 April 2012 - 08:52 PM.

Michael Vinther

#2 jake2k

jake2k
  • Members
  • 1,363 posts
  • LocationDunedin, Florida
  • Reputation:6

Posted 16 March 2009 - 06:15 PM

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

Posted Image

^Click to visit my Flickr Gallery^


#3 Leif

Leif
  • Members
  • 672 posts
  • LocationDenmark
  • Reputation:0

Posted 16 March 2009 - 06:59 PM

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
Posted Image
My DA: http://leif-j.deviantart.com/
--------------
Some people seek justice so persistent, that they will do great injustice themselves.

#4 david.atwell

david.atwell

    Former Moderator

  • Members
  • 627 posts
  • LocationIndianapolis, IN (39°46′5.88″N 86°9′29.52″W)
  • Reputation:18

Posted 16 March 2009 - 07:39 PM

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...)

Posted Image

The Doctor: There was a goblin, or a trickster, or a warrior... A nameless, terrible thing, soaked in the blood of a billion galaxies. The most feared being in all the cosmos. And nothing could stop it, or hold it, or reason with it. One day it would just drop out of the sky and tear down your world.
Amy: But how did it end up in there?
The Doctor: You know fairy tales. A good wizard tricked it.
River Song: I hate good wizards in fairy tales; they always turn out to be him.


#5 Juraiko1324

Juraiko1324
  • Members
  • 574 posts
  • LocationIn your hair.
  • Reputation:0

Posted 16 March 2009 - 08:36 PM

Mine encountered a bug and PDN restarted. =X


Posted Image

-I may have not been here when you passed away, but you will be missed.-


#6 MichaelVinther

MichaelVinther
  • Members
  • 23 posts
  • LocationDenmark
  • Reputation:0

Posted 16 March 2009 - 08:45 PM

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.
Michael Vinther

#7 Rick Brewster

Rick Brewster

    Paint.NET Author and Developer

  • Administrators
  • 12,609 posts
  • LocationKirkland, WA
  • Reputation:125

Posted 16 March 2009 - 10:15 PM

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.
The Paint.NET Blog: http://blog.getpaint.net/
Donations are always appreciated! http://www.getpaint.net/donate.html

Posted Image

#8 Rick Brewster

Rick Brewster

    Paint.NET Author and Developer

  • Administrators
  • 12,609 posts
  • LocationKirkland, WA
  • Reputation:125

Posted 16 March 2009 - 10:21 PM

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.
The Paint.NET Blog: http://blog.getpaint.net/
Donations are always appreciated! http://www.getpaint.net/donate.html

Posted Image

#9 MichaelVinther

MichaelVinther
  • Members
  • 23 posts
  • LocationDenmark
  • Reputation:0

Posted 16 March 2009 - 10:42 PM

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%.
Michael Vinther

#10 joshbl56

joshbl56
  • Members
  • 16 posts
  • Reputation:0

Posted 17 March 2009 - 02:44 AM

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)


#11 pyrochild

pyrochild

    Plugin Author of the Year 2012

  • Administrators
  • 11,273 posts
  • LocationColorado
  • Reputation:137

Posted 17 March 2009 - 02:55 AM

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.
sig8.png
[I write plugins and stuff]

If you like a post, upvote it!

#12 Rick Brewster

Rick Brewster

    Paint.NET Author and Developer

  • Administrators
  • 12,609 posts
  • LocationKirkland, WA
  • Reputation:125

Posted 18 March 2009 - 05:09 AM

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 :)
The Paint.NET Blog: http://blog.getpaint.net/
Donations are always appreciated! http://www.getpaint.net/donate.html

Posted Image

#13 Fisherman's Friend

Fisherman's Friend
  • Members
  • 490 posts
  • LocationCoruscant
  • Reputation:0

Posted 18 March 2009 - 03:20 PM

Posted Image

Could anyone please write the correct string for the Photo submenu? I mean the localizeable version.

#14 Tim!

Tim!
  • Members
  • 35 posts
  • Reputation:0

Posted 18 March 2009 - 03:28 PM

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

#15 Tanel

Tanel
  • Members
  • 215 posts
  • Reputation:6

Posted 19 March 2009 - 10:25 AM

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:


BTW, are you the guy who created Image Analyzer?
I have learnt a lot of things whith that program, really appreciate! :)

#16 MichaelVinther

MichaelVinther
  • Members
  • 23 posts
  • LocationDenmark
  • Reputation:0

Posted 19 March 2009 - 10:31 PM

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.
Michael Vinther

#17 Rick Brewster

Rick Brewster

    Paint.NET Author and Developer

  • Administrators
  • 12,609 posts
  • LocationKirkland, WA
  • Reputation:125

Posted 20 March 2009 - 06:29 PM

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.
The Paint.NET Blog: http://blog.getpaint.net/
Donations are always appreciated! http://www.getpaint.net/donate.html

Posted Image

#18 Rick Brewster

Rick Brewster

    Paint.NET Author and Developer

  • Administrators
  • 12,609 posts
  • LocationKirkland, WA
  • Reputation:125

Posted 20 March 2009 - 06:32 PM

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.

And I just replied :)
The Paint.NET Blog: http://blog.getpaint.net/
Donations are always appreciated! http://www.getpaint.net/donate.html

Posted Image

#19 Fisherman's Friend

Fisherman's Friend
  • Members
  • 490 posts
  • LocationCoruscant
  • Reputation:0

Posted 21 March 2009 - 07:05 PM

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.

#20 MichaelVinther

MichaelVinther
  • Members
  • 23 posts
  • LocationDenmark
  • Reputation:0

Posted 22 March 2009 - 09:19 PM

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