Plug-in SDK

Upcoming mother of all image editors
JEL
Posts: 295
Joined: Fri Jan 06, 2012 9:35 pm
Contact:

Re: Plug-in SDK

Post by JEL »

andydansby wrote:I certainly can make the filter copy luminance from one image to another. That should be fairly easy to do within the same algorithm, which is just mean and standard deviation of image B applied to image A. I'm not sure how to copy contrast from one image to another, I don't know how contrast can be measured, but I sure that someone has figured it out somewhere.
Yes I think I meant luminance :) (I guess I mixed the concepts up)

I got interested in this because I read about a method where the histogram was stretched into a bell-curve shape, and it was explained that that was the ideal shape for most images in terms of brightness (luminance). But the math behind it is just over my head, but should be in the neighborhood of what you're doing with the color-transfer plugin :)

The method described was an alternative to the normal histogram-equalize algorithm and calls it a 'gaussian redistribution of the histogram' (it's all way over my head unfortunately)

I found it on this link:
http://www.imagemagick.org/Usage/color_ ... ian_redist

If I knew more about how to do the math parts of this idea, I would've tried it in the CPP-script block (I'm not advanced enough for actual CPP, requiring Microsoft's compiler. I've tried it a few times but it's somewhat like stepping into a pool of quicksand for me; I always get stuck and find it's mostly just trouble and weird errors that rarely makes any sense to me. The script-block in photo-reactor I can work with, barely, but I just have no idea how to begin coding for this 'gaussian redistribution' idea.)

Anyway, maybe you want to look into this someday (I'd certainly be a taker of such a plugin :) IF the idea is actually as useful as they describe it). Or maybe, when you release the source-code, I can hack something up from it that works in the script-block :)
DAP (AOPs): http://jelstudio.dk/DAP/
PhotoReactor (flows, effects and scripts): http://jelstudio.dk/PhotoReactor/

andydansby
Posts: 161
Joined: Fri Oct 29, 2010 6:00 am
Location: Syracuse, NY

Re: Plug-in SDK

Post by andydansby »

Been away for a while, been really busy.


before
before
before
lizard.jpg (108.41 KiB) Viewed 5441 times

after
after
after
lizard_Final.jpg (89.37 KiB) Viewed 5441 times

This is another separable bilateral 609ms for my 500x500 test image. Just a test of quality for separable bilateral. Radius 8, Color difference .262

Code to follow when I get a free moment. I owe several routines to the guide, just been busy.


Andy Dansby

andydansby
Posts: 161
Joined: Fri Oct 29, 2010 6:00 am
Location: Syracuse, NY

Re: Plug-in SDK

Post by andydansby »

This is a new filter ABES (Andy's Bi Exponential Smoother. While playing around with Bilateral smoothing I accidentally came up with this. This particular smoothing effect just uses radius to collect all the colors and by using the Euclidean distance we can determine the edges within the radius. The results are pretty good and fairly fast.

Enough talking for now, here's the filters
ABES 32bit.zip
32 bit version
(53.21 KiB) Downloaded 281 times
32 bit version
ABES 64bit.zip
64 bit version
(54.78 KiB) Downloaded 305 times
64 bit version

Here's some results

Original
Original
Original
greekdome.jpg (63.38 KiB) Viewed 5399 times
ABES Filtered
greekdome_Final.jpg
greekdome_Final.jpg (116.46 KiB) Viewed 5399 times
Using 10 Radius, took about 2 seconds


Enjoy
Andy Dansby

smmsamm
Posts: 321
Joined: Tue Oct 26, 2010 7:58 pm

Is it possible to make a plugin like this?

Post by smmsamm »

ComputerGeneratedPainting.jpg
ComputerGeneratedPainting.jpg (103.3 KiB) Viewed 5325 times

http://gurneyjourney.blogspot.com/2010/ ... nting.html

Image Parsing
http://gurneyjourney.blogspot.com/2012/ ... rsing.html
Photo.sm.jpg
Photo.sm.jpg (95.05 KiB) Viewed 5325 times
a_painting.jpeg
a_painting.jpeg (225.4 KiB) Viewed 5325 times

andydansby
Posts: 161
Joined: Fri Oct 29, 2010 6:00 am
Location: Syracuse, NY

Re: Plug-in SDK

Post by andydansby »

Dear smmsamm:

I am certain that within certain constraints, given enough time, effort and know-how, something could be created like this. As I read the articles, someone has already created the code and are already doing this. If this is a project you want to tackle yourself, happy coding, just realize this this probably would be a large project to tackle.

If you are asking if I want to code this, the answer is no for several reasons. Not enough free time on my hands and probably not enough personal interest to try to recreate DAP, which this is, nor am I interested in trying to compete with Oscar on his own product with his own product. Perhaps Oscar will offer a way to push images from Photo-Reactor to DAP and then back to Photo-Reactor.

My interest lies in pure image processing and the math that goes with it which I find personally interesting if even sometimes are too advanced for me.

The article on Image Parsing, which sounds exactly on how DAP works. A number of brushes and/or strokes are stored and applied to a photograph in a manner from larger to smaller. The end results on the article look great!

There are a number of different types of photo to painting algorithms out there and not all of them are like the DAP way of doing things, you could explore those first if you wish to code something like those. I may (or may not) explore those alternate techniques in the future depending on interest and time.

Andy

andydansby
Posts: 161
Joined: Fri Oct 29, 2010 6:00 am
Location: Syracuse, NY

Re: Plug-in SDK

Post by andydansby »

Jel:

I have been trying to accomplish the Gaussian Redistribution of the Histogram. From best as what I have been able to find, one would have to create an internal histogram, i.e. Bins, one for each color in the image. So for example, a 256 color RGB image would have to have 3 256 Byte arrays. Using these BINs, you create a cumulative distribution array then reshape that with a Gaussian formula. That includes finding the standard distribution. A rather lengthy process and limited.

If you use a 16 bit color image, you would have to create 3 65535 byte arrays, yuck!

Since I have been working with image in a normalized 0-1 space, creating a BIN to hold every floating point would make the process even more complex. (Counting the colors of each RGB, then placing them into the separate bins.)

However, there seems to be a simpler way to do this without creating BINs, satisfies my use of floating point 0-1 arrays and fast. This is by using a Sigmoid Function (S-Curve), more specifically the Gudermannian Sigmoid (http://en.wikipedia.org/wiki/Gudermannian_function). The math seems complex on the Wikipedia site, but is not really that complex at all. I will post the code later in my Beginning Image processing guide, since the function is a pixel point operation.

The Non-Linear Brightening function works well and does seems to brighten the image in a more natural way than a histogram stretch.

Here is the 32 bit version of the plugin
Gudermannian.zip
32 bit version
(39.67 KiB) Downloaded 284 times
When I get a free moment, I'll compile a 64 bit version


Andy Dansby

JEL
Posts: 295
Joined: Fri Jan 06, 2012 9:35 pm
Contact:

Re: Plug-in SDK

Post by JEL »

Hi Andy; Both methods are over my skill-level (not really good with math), but I am certainly looking forward to the 64bit version of this regardless of which mathematical method you utilize to accomplish the effect :)

The traditional histogram-stretch is very hit'n'miss. Looks very good occasionally, but equally terrible on other images. And I find its effect hard to anticipate, which makes it impossible, for me at least, to prep my image such that it will suit the histogram-stretch effect.

Your plugins and source-code examples are very much appreciated Andy :)
Thank you.
DAP (AOPs): http://jelstudio.dk/DAP/
PhotoReactor (flows, effects and scripts): http://jelstudio.dk/PhotoReactor/

andydansby
Posts: 161
Joined: Fri Oct 29, 2010 6:00 am
Location: Syracuse, NY

Re: Plug-in SDK

Post by andydansby »

Thanks Jel, figuring out the various ways to program the various image processing techniques is interesting for me. Some are too complex for me as well. The Gudermannian Sigmoid though was not as bad as I originally thought.

First of all here are the plugins
Gudermannian x32.zip
(39.67 KiB) Downloaded 266 times
the 32 bit version
Gudermannian x64.zip
(42.63 KiB) Downloaded 320 times
the 64 bit version

First there are two controls, one for Gain and one for Histogram shift. The gain is from .1 to 1.5 with a default of .65 (no Shift). The Histogram shift is from -.5
to .5 with a default of 0.

The image is placed in the floating point 0-1 space .

I place the image in a temp array.

Here is the snippet of code that does the work.

{
double gain = nGain;
double cutoff = nCutoff;
double pi = 3.1415926535897932f;
for (int x = 0; x < nWidth; x++)
{
for (int y = 0; y < nHeight; y++)
{
int nIdx = x * 4 + y * 4 * nWidth;
double red = temp[nIdx + CHANNEL_R];
double green = temp[nIdx + CHANNEL_G];
double blue = temp[nIdx + CHANNEL_B];

double rr = (pi / 2.0f) * (gain * (red + cutoff));
double gg = (pi / 2.0f) * (gain * (green + cutoff));
double bb = (pi / 2.0f) * (gain * (blue + cutoff));

output[nIdx + CHANNEL_R] = (rr);
output[nIdx + CHANNEL_G] = (gg);
output[nIdx + CHANNEL_B] = (bb);
}
}
}

The image is then stretched back to 0-255 space making sure to clamp to 0-255 space that that's it.

Easy Peasy

Andy Dansby

andydansby
Posts: 161
Joined: Fri Oct 29, 2010 6:00 am
Location: Syracuse, NY

Re: Plug-in SDK

Post by andydansby »

Well I am releasing another plugin. Surface Blur, also known by some other names, Smart Blur, Selective Gaussian Blur and perhaps some other names. It is closely related to the Bilateral Blur. This version is separable and zippy fast. This comes from a math simplification and the fact that it is separable.

I placed a test image earlier of the lizard and reported a time of .609ms for a 500x500 image. With some code modification and pure luck, the speed is improved to .250 ms. Not too shabby at all.

It may seem like I am releaseing one filter immediately after another, the fact is that I have been playing around with the surface blur for much longer than I intended.

Here's the plugins
SurfaceBlur x32.zip
(53.3 KiB) Downloaded 278 times
the 32 bit version
SurfaceBlur x64.zip
(56.16 KiB) Downloaded 325 times
the 64 bit version

As always, I will post the code eventually in my intermediate image processing guide for others to study, copy or do whatever with.

enjoy
Andy Dansby

JEL
Posts: 295
Joined: Fri Jan 06, 2012 9:35 pm
Contact:

Re: Plug-in SDK

Post by JEL »

andydansby wrote:The Gudermannian Sigmoid

Easy Peasy

Andy Dansby
This is amazing!!! The best brightness-control I've seen so far. It even beats the 'exposure' block!!

This should be made standard in PhotoReactor!
It maintains color and contrast and overall clarity much better than any other method I've tried up to this point.

Fantastic work Andy!!! :)
DAP (AOPs): http://jelstudio.dk/DAP/
PhotoReactor (flows, effects and scripts): http://jelstudio.dk/PhotoReactor/

Post Reply