Jump to content


Photo

Combined Photo Adjustments - With source code (Jan 19, 2010)


  • Please log in to reply
16 replies to this topic

#1 BoltBait

BoltBait
  • Administrators
  • 8,906 posts
  • LocationCalifornia, USA
  • Reputation:103

Posted 18 January 2010 - 11:48 PM

I was processing a large set of photos the other day and was getting frustrated that I needed to run 4-5 different effects on each photo. I thought that all of these adjustments should be on the same UI so that I could just run one effect. So, that's what I built. (Nothing new here, just a combination of a bunch of effects.)

Posted Image

It saved me a ton of time processing those photographs as the sliders were remembered between each run.

Hopefully you'll find this useful too.

To install, download this file to your C:/Program Files/Paint.NET/Effects folder and unzip it. :PlusButton:

Download here

Tested with Paint.NET version 3.36 and above.

Here's the CodeLab source:

// Author: BoltBait
// Submenu: Photo
// Name: Combined Adjustments
// URL: http://www.BoltBait.com/pdn
// Title: BoltBait's Photo Adjustments v1.1
#region UICode
double Amount1 = 0.2; // [0,1] Noise Reduction
int Amount2 = -10; // [-100,100] Brightness
int Amount3 = 10; // [-100,100] Contrast
int Amount4 = 1; // [-10,10] Yellow                                                      Blue
int Amount5 = 5; // [-100,100] Saturation
int Amount6 = 30; // [0,100] Final Multiply Adjustment
#endregion

// Setup for using the various blend ops
private UserBlendOps.MultiplyBlendOp multiplyOp = new UserBlendOps.MultiplyBlendOp();
private UnaryPixelOps.HueSaturationLightness saturationOp;

// Rick, stop moving stuff around!
private byte Clamp2Byte(int iValue)
{
    if (iValue<0) return 0;
    if (iValue>255) return 255;
    return (byte)iValue;
}

unsafe void Render(Surface dst, Surface src, Rectangle rect)
{
    Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
    saturationOp = new UnaryPixelOps.HueSaturationLightness(0, 100+Amount5, 0);
    
    // Setup for calling the Noise Reduction function
    ReduceNoiseEffect noiseEffect = new ReduceNoiseEffect();
    PropertyCollection nProps = noiseEffect.CreatePropertyCollection();
    PropertyBasedEffectConfigToken nParameters = new PropertyBasedEffectConfigToken(nProps);
    nParameters.SetPropertyValue(ReduceNoiseEffect.PropertyNames.Radius, 10);
    nParameters.SetPropertyValue(ReduceNoiseEffect.PropertyNames.Strength, Amount1);
    noiseEffect.SetRenderInfo(nParameters, new RenderArgs(dst), new RenderArgs(src));
    // Call the Reduce Noise function
    noiseEffect.Render(new Rectangle[1] {rect},0,1);

    // Setup for calling the Brightness and Contrast function
    BrightnessAndContrastAdjustment bacAdjustment = new BrightnessAndContrastAdjustment();
    PropertyCollection cProps = bacAdjustment.CreatePropertyCollection();
    PropertyBasedEffectConfigToken cParameters = new PropertyBasedEffectConfigToken(cProps);
    cParameters.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Brightness, Amount2);
    cParameters.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Contrast, Amount3);
    bacAdjustment.SetRenderInfo(cParameters, new RenderArgs(dst), new RenderArgs(dst));
    // Call the Brightness and Contrast function
    bacAdjustment.Render(new Rectangle[1] {rect},0,1); 

    // Now in the main render loop, the dst canvas has a fixed up version of the src canvas
    for (int y = rect.Top; y < rect.Bottom; y++)
    {
        ColorBgra* srcPtr = src.GetPointAddressUnchecked(rect.Left, y);
        ColorBgra* dstPtr = dst.GetPointAddressUnchecked(rect.Left, y);
        for (int x = rect.Left; x < rect.Right; x++)
        {
            // Boost the saturation
            *dstPtr = saturationOp.Apply(*dstPtr);
            // Yellow-Blue adjustment
            ColorBgra SourcePixel = *dstPtr;
            SourcePixel.R = Clamp2Byte(SourcePixel.R - Amount4/2);
            SourcePixel.G = Clamp2Byte(SourcePixel.G - Amount4/2);
            SourcePixel.B = Clamp2Byte(SourcePixel.B + Amount4);
            *dstPtr = SourcePixel;
            // Finally, add a little "punch" to the overall picture
            ColorBgra DestPixel = *dstPtr;
            DestPixel.A = (byte)(int)(Amount6 * 255.0 / 100.0);
            *dstPtr = multiplyOp.Apply(*dstPtr, DestPixel);

            srcPtr++;
            dstPtr++;
        }
    }
} 

This is now included in my plugin pack.
Click to play:
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image
Download: BoltBait's Plugin Pack | CodeLab | More... and how about a Computer Dominos Game

#2 Simon Brown

Simon Brown
  • Members
  • 10,185 posts
  • Reputation:15

Posted 19 January 2010 - 12:04 AM

Doesn't ScriptLab solve that problem (although it doesn't let you easily change the settings for each photo)?
Posted Image

#3 Ego Eram Reputo

Ego Eram Reputo

    Master of Competition Ideas and 2012 Proton Award Winner

  • Moderators
  • 5,613 posts
  • LocationNorth Canterbury, New Zealand
  • Reputation:217

Posted 19 January 2010 - 02:03 AM

I immediately thought of Tanel's Photo Adjustments. But I see yours has quite different functions.

I can see that I'd use both frequently. I love that you have supplied the source!

Did you consider including a "sharpen" feature?

#4 Mike Ryan

Mike Ryan
  • Competition Hosts
  • 4,263 posts
  • Reputation:9

Posted 19 January 2010 - 02:06 AM

Really cool! It would be pretty awesome if there was a slider that controlled the Portrait plugin of yours and the reverse effect. I find it useful, but mostly because it gives me more source code to go over. Good plugin and idea, and I would recommend packaging it if others feel the same :P

Posted Image


#5 sandiee

sandiee
  • Members
  • 42 posts
  • Reputation:0

Posted 19 January 2010 - 02:35 AM

Whenever I go to use it, It comes up with an error and i have to restart paint.net..

Posted Image


#6 BoltBait

BoltBait
  • Administrators
  • 8,906 posts
  • LocationCalifornia, USA
  • Reputation:103

Posted 19 January 2010 - 03:01 AM

Whenever I go to use it, It comes up with an error and i have to restart paint.net..

This plugin requires the latest build of Paint.NET. Upgrade Paint.NET and it should work fine.
Click to play:
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image
Download: BoltBait's Plugin Pack | CodeLab | More... and how about a Computer Dominos Game

#7 sandiee

sandiee
  • Members
  • 42 posts
  • Reputation:0

Posted 19 January 2010 - 03:09 AM

Whenever I go to use it, It comes up with an error and i have to restart paint.net..

This plugin requires the latest build of Paint.NET. Upgrade Paint.NET and it should work fine.


For some reason ive always been hesistant to download the new version..Whats the difference and where can i download it?

Posted Image


#8 BoltBait

BoltBait
  • Administrators
  • 8,906 posts
  • LocationCalifornia, USA
  • Reputation:103

Posted 19 January 2010 - 04:39 PM

Whenever I go to use it, It comes up with an error and i have to restart paint.net..

This plugin requires the latest build of Paint.NET. Upgrade Paint.NET and it should work fine.

This is no longer true.

I recompiled the plugin against Paint.NET 3.36 so you should download it again and it will work with your version of Paint.NET.
Click to play:
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image
Download: BoltBait's Plugin Pack | CodeLab | More... and how about a Computer Dominos Game

#9 BoltBait

BoltBait
  • Administrators
  • 8,906 posts
  • LocationCalifornia, USA
  • Reputation:103

Posted 19 January 2010 - 04:48 PM

I immediately thought of Tanel's Photo Adjustments. But I see yours has quite different functions.

I can see that I'd use both frequently. I love that you have supplied the source!

Did you consider including a "sharpen" feature?

Yes, mine is quite different from Tanel's. :)

I usually don't need to sharpen my indoor photos (which this is designed for) since the focus is not set to infinity.

I did include a sharpen function in my Landscape plugin (which is designed for outdoor photos). Have you tried that?
Click to play:
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image
Download: BoltBait's Plugin Pack | CodeLab | More... and how about a Computer Dominos Game

#10 sandiee

sandiee
  • Members
  • 42 posts
  • Reputation:0

Posted 20 January 2010 - 01:25 AM

Thankyou for allowing it to be used in the older version of paint.net :)

Posted Image


#11 Lance McKnight

Lance McKnight
  • Members
  • 1,230 posts
  • Reputation:4

Posted 20 January 2010 - 01:49 AM

I can see usefulness for landscaping picture (working in tandem with Landscape plugin) or to improve texture that I plan to make soon (if I ever find the time...)

Reading the source code made me cross-eyed, but I was wondering what effects did you pull together to make this plugin?

*downloads*

Officially retired from this forum. Have a nice day.


#12 BoltBait

BoltBait
  • Administrators
  • 8,906 posts
  • LocationCalifornia, USA
  • Reputation:103

Posted 20 January 2010 - 02:02 AM

Reading the source code made me cross-eyed, but I was wondering what effects did you pull together to make this plugin?

OK, this is a combination of the following controls (top to bottom):

1. The Strength slider from the Effects > Noise > Reduce Noise effect
2&3. The Brightness and Contrast sliders from the Adjustments > Brightness/Contrast effect
4. The Yellow-Blue slider from my Adjustments > Color Balance plugin
5. The Saturation slider from the Adjustments > Hue/Saturation effect
6. Um... This last slider actually simulates the following:
-Duplicate the layer
-Change the top duplicate layer to blend mode Multiply
-This slider is now the Opacity slider of the top duplicate layer's property box
Basically, it functions like a Contrast adjustment for Saturation.

Clear? ;)
Click to play:
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image
Download: BoltBait's Plugin Pack | CodeLab | More... and how about a Computer Dominos Game

#13 Lance McKnight

Lance McKnight
  • Members
  • 1,230 posts
  • Reputation:4

Posted 20 January 2010 - 02:45 AM

It is as clear as a chocolate pie on the back of a wet elephant.

Thanks though for taking the time to explain how it works. Now that I have the information, I'm sure to fire it up soon, and crank out some photomanips.

Officially retired from this forum. Have a nice day.


#14 Ego Eram Reputo

Ego Eram Reputo

    Master of Competition Ideas and 2012 Proton Award Winner

  • Moderators
  • 5,613 posts
  • LocationNorth Canterbury, New Zealand
  • Reputation:217

Posted 20 January 2010 - 04:07 AM

I usually don't need to sharpen my indoor photos (which this is designed for) since the focus is not set to infinity.

That makes perfect sense.

I did include a sharpen function in my Landscape plugin (which is designed for outdoor photos). Have you tried that?

I have both Sharpen and Sharpen+ installed and usually dive straight for those. To be honest I doubt I'd look to your Landscape plugin for a sharpen unless I was also using some of the other features as well.

Thanks for this plugin. It will be very useful! 8)

#15 Neil Cassidy

Neil Cassidy
  • Members
  • 71 posts
  • Reputation:0

Posted 22 January 2010 - 09:36 AM

Thanks for this, Boltbait! It's useful in and of itself as a single consolidated way to make a number of adjustments, and the source code is a great example of how to compose effects (and by composition, I mean function composition).

Segment Image : Average Color (HSL) : Eigen Blur : []
Cool, new forum!


#16 Rick Brewster

Rick Brewster

    Paint.NET Author and Developer

  • Administrators
  • 12,554 posts
  • LocationKirkland, WA
  • Reputation:120

Posted 27 January 2010 - 12:13 AM

Thankyou for allowing it to be used in the older version of paint.net :)

Umm ... why don't you just install the latest version of Paint.NET :? :?:
The Paint.NET Blog: http://blog.getpaint.net/
Donations are always appreciated! http://www.getpaint.net/donate.html

Posted Image

#17 L3ron

L3ron
  • Members
  • 436 posts
  • LocationLower Saxony
  • Reputation:0

Posted 07 March 2010 - 04:00 PM

Very cool effects! This should be included with PDN 3.5.5! :D


Posted Image
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image