Jump to content


Photo

Average Color (HSL) v1.1


  • Please log in to reply
2 replies to this topic

#1 Neil Cassidy

Neil Cassidy
  • Members
  • 71 posts
  • Reputation:0

Posted 10 November 2009 - 06:51 PM

Update: Performance and stability fix, see post below for details!

Hi everyone,

Here's my second plug-in, "Average Color (HSL)". The original idea for this plugin is due to phrebh, who brought this up in the other thread. It's based on the observation that averaging the color of a selection might make more sense in a color space that better reflects human perception of color than sRGB does. I would have used CIELAB, but an average of valid sRGB colors in CIELAB space won't necessarily yield another valid sRGB color.

The following examples demonstrate how this effect differs from a comparable plugin that averages the RGB values directly, Average Color of Selection. I ran each effect on twelve different blocks of each image.
Posted Image

Image attribution: Candy, Landscape. The pixels on the left half of the test pattern are all fully saturated.

Many thanks to the following people for helping to make this plugin possible: Rick Brewster, Tom Jackson, BoltBait, Sepcot, phrebh, and MJW. As usual, install by copying the .dll to your effects directory. License (MIT) is included in the archive. Enjoy!

I'll be glad to release the source if anyone would like it, but the project is a little disorganized right now, so I'll have to clean it up first. Let me know...

Version 1.0 was downloaded 369 times.

Attached Files


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


#2 Frontcannon

Frontcannon
  • Members
  • 2,302 posts
  • LocationNorth-Rhine Westphalia, Germany
  • Reputation:4

Posted 10 November 2009 - 07:11 PM

Respect, thank you very much :)

#3 Neil Cassidy

Neil Cassidy
  • Members
  • 71 posts
  • Reputation:0

Posted 06 February 2010 - 07:49 PM

Updated. A really bad memory leak has been fixed! See first post for download.

I was preallocating a large arraylist to avoid dynamic expansion and associated heap fragmentation, but instead of doing this only once, I was doing it for every region of interest. So I was using the effect on some large non-contiguous selections this morning, obtained by using Segment Image and Magic Wand, and got some out-of-memory errors. I fixed it up immediately and did a little refactoring.

It shouldn't run out of virtual memory anymore, and performance is greatly improved (although still not optimal).

Other changes:
- Effect has been moved to the "Color" sub-menu.
- Analysis stage has been moved to OnSetRenderInfo method. The double-checked lock + memory barrier hack isn't necessary unless the effect is built in Code Lab.
- Instead of scanning over the selection's bounding box and using the IsVisible test to determine whether a given pixel within the box is actually selected, it now scans over the regions of interest directly, which also improves performance.

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