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 »

I hacked down a lighter script-block version of Andy Dansby's "The Gudermannian Sigmoid" plugin.

It's less advanced but does have the brighten effect.

The gain slider has 32 as neutral (below 32 the image gets darker, above it gets brighter)
I didn't include the offset control.

To Andy's credit :)


Code: Select all

//Increase brightness
//##NAME:Andy's Gudermannian brightness code
//##DESCRIPTION:Andy's Gudermannian brightness code modified by JEL for the PR script-block.
//##INPUTS:1
//##VAR1:32
//##VAR1_NAME:Gain

void main()
{
	// get the image from input socket
	image img(INPUT);
  	int width = img.width;
	int height = img.height;

	double gain = 1.5;
	double pi = 3.1415926535897932f;
	
	for (int y=0; y<height; y++)
	{
		for (int x=0; x<width; x++)
		{

			float gain = VAR1/50.0;

			// one way to get color from pixel
			pixel color = img.Pixel(x,y);

			double rr = (pi / 2.0) * (gain * color.r);
			double gg = (pi / 2.0) * (gain * color.g);
			double bb = (pi / 2.0) * (gain * color.b); 

			img.SetRGB(x, y,rr,gg,bb);

		}
	
	}

	
	// send the image to output
	img.SetOutput();
	
}
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 »

Hello everyone:

I have been working on for a while a filter that produces an Anisotropic Diffusion and have finally completed the coding. Let's start off with a test image from the Kodak library.


Here is the original image
kodim19.png
kodim19.png (655.74 KiB) Viewed 7868 times
Here is a Anisotropic Diffusion filtered image
kodim19_Final Anisotropic Diffusion.jpg
kodim19_Final Anisotropic Diffusion.jpg (162.53 KiB) Viewed 7868 times
At lower iterations, it is a noise reduction filter, at higher iterations, it is a noise reduction and edge preservation. The test image is at 26 iterations and .050 sigma.

Here is the filter

32 Bit
AnisotropicDiffusion 32bit.zip
32 bit
(52.96 KiB) Downloaded 383 times
64 Bit
AnisotropicDiffusion 64bit.zip
64 bit
(54.75 KiB) Downloaded 426 times
Of course when I get a moment, the source code will be placed in my intermediate image processing guide.

enjoy
Andy Dansby

jenniferwilson
Posts: 1
Joined: Thu Jul 17, 2014 10:57 pm

Re: Plug-in SDK

Post by jenniferwilson »

right now, i am working on this project about qr code sdk for c#.net. need some brilliant idea, any help would be appreciated.
if you are good at VB.net, i'd love to know as well.

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

Re: Plug-in SDK

Post by andydansby »

Hi Everyone:

I have been working on a new plugin. No particular ETA on this one as it has been difficult for me to find a good working sample to base it on. This is a noise reduction filter called Total Variation. It seems to be decent at removing Gaussian noise.

Before
Before
Before
circuit.png (58.22 KiB) Viewed 7598 times

After
circuit_Final.jpg
circuit_Final.jpg (37.19 KiB) Viewed 7598 times
Thanks

Andy Dansby

---
Correction 8-1-14
This is mean curvature, not total variation. I have yet to crack the flow for total variation yet. Even so it is a neat-o filter. It's slow and a memory hog, but I like the results so far.

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

Re: Plug-in SDK

Post by andydansby »

OK, this one is closer to Total Variation
circuit.png
circuit.png (58.22 KiB) Viewed 7528 times
Before
circuit_Final.jpg
circuit_Final.jpg (18.29 KiB) Viewed 7528 times
After



Andy

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

Re: Plug-in SDK

Post by andydansby »

Here's another test


Original Image
lena 256x256 original.jpg
lena 256x256 original.jpg (55.02 KiB) Viewed 7528 times

Image corrupted with 65% noise
lena 256x256 noise added.jpg
lena 256x256 noise added.jpg (185 KiB) Viewed 7528 times
Total Variation 80 iterations
lena total variation_Final.jpg
lena total variation_Final.jpg (19.79 KiB) Viewed 7528 times

Not perfect, but still playing around.

Andy Dansby

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

Re: Plug-in SDK

Post by andydansby »

For comparison, here's the G'Mic version at 2 - 40 iteration passes.
lena 256x256 TV GMIC.jpg
lena 256x256 TV GMIC.jpg (89.97 KiB) Viewed 7528 times
Compared against my version
lena total variation_Final.jpg
lena total variation_Final.jpg (19.79 KiB) Viewed 7528 times
The two are fairly close.


Andy Dansby

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

Re: Plug-in SDK

Post by andydansby »

Here is a filter that has been bouncing in my collection for a little while and I never released it. The separable bilateral blur. This is certainly different than my Max Bilateral which has a completely different output and certainly different than the built in Bilateral. This is a linearized close approximation of the Bilateral Blur. It has 4 different kernels inspired by the work of Tuan Q. Pham and Lucas J. van Vliet for the separable part and Manasi Datar for the Kernel part.

Anyway enough with the intro
SeparableBilateral 32 Bit.zip
(67.14 KiB) Downloaded 366 times
the 32 bit version
SeparableBilateral 64 bit.zip
(60.46 KiB) Downloaded 389 times
the 64 bit version


Enjoy

Andy Dansby

BTW the code will be available in my Intermediate Image processing guide after code cleanup

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

Re: Plug-in SDK

Post by JEL »

Hi Andy, I have a question I think you're the only one here who can answer :)

I've been over your SDK guide, but couldn't find what I was looking for. And I'm not good enough friends with CPP to be able to figure it out myself.

I have an image... a bayer-mosaic (a raw-file that hasn't been debayered/demosaiced).

This image is made up of 2x2 squares, with 1 red, 1 blue, and 2 green pixels. They are placed in the same order in each 2x2 square.

My goal is to have a script in the script node that can take the red and copy it to the 3 other pixels in its square, and take the blue and copy that to the 3 other pixels, and take the 2 greens and average them and then copy them to the 2 other pixels (or just take 1 green and treat the same way as done with the red and blue)
Am I making sense?

My problem is that I can't figure out how to read such 2x2 squares. I can figure out how to read single pixels, but not these... I guess they're called... bi-cubic squares.

I've attached a crop of one such bayer-mosaic.

The point of it all is to be able to attempt my own routines at demosaicing.

I imagine you already know how to look at adjacent pixels, since I guess that's needed for your denoise/blur plugins, so is this something you will include in your SDK guide?
Thanks
Attachments
BayerPatternCrop.png
BayerPatternCrop.png (238 Bytes) Viewed 7322 times
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 »

Hi Jel:

I have to do some revamping in my guides, however that little nugget on addressing adjacent pixels is found in the intermediate image processing guide. I'll probably get around to it in the late fall / winter time. Summertime is for house repair and yard work.

https://skydrive.live.com/redir?resid=A ... ile%2c.pdf.

If you want nested loops that look in the 1d directions, look at the Gaussian Blur vertical and horizontal. If you want nested loops that look in the 2d direction, look at the Gaussian Blur 2d. The difference is in the separability of the filter. If you have a 2d nested loop, it is always slower than the 1d nested loop.


Here is an example of the 2d nested loops, which is used for Non-Linear filter

for(int y = 0; y < nHeight; y++)
{
for(int x = 0; x < nWidth; x++)
{
int ctrIdx = y * nWidth + x;
float redcenter; float greencenter; float bluecenter;

float redcenter = pBGRA_in[(ctrIdx) * 4 + CHANNEL_R];
float greencenter = pBGRA_in[(ctrIdx) * 4 + CHANNEL_G];
float bluecenter = pBGRA_in[(ctrIdx) * 4 + CHANNEL_B];

for(int j = max(0, y - size); j <= MIN(nHeight - 1, y + size); j++)
{
for(int i = max(0, x - size); i <= MIN(nWidth - 1, x + size); i++)
{
int idx = max(0, min(j, nHeight-1))*nWidth + max(0, min(i,nWidth-1));

float redKernelSlider = pBGRA_in[(idx) * 4 + CHANNEL_R];
float greenKernelSlider = pBGRA_in[(idx) * 4 + CHANNEL_G];
float blueKernelSlider = pBGRA_in[(idx) * 4 + CHANNEL_B];

//do your routine here
}//end I
}//end J
}//end x
}//end y

//////////////////////////////////////////////////////////////////////

The redcenter, greencenter and bluecenter are the center pixel of an odd sized kernel. While the redKernelSlider, greenKernelSlider and blueKernelSlider slide along the kernel to collect the pixel values in a 2d fashion.

The 1d example

for(int y = 0; y < nHeight; y++)
{
for(int x = 0;x < nWidth; x++)
{
for(int i = max(0, x - size); i <= MIN(nWidth - 1, x + size); i++)
{
float red = pBGRA_in[(i + y * nWidth) * 4 + CHANNEL_R];
float green = pBGRA_in[(i + y * nWidth) * 4 + CHANNEL_G];
float blue = factor * pBGRA_in[(i + y * nWidth) * 4 + CHANNEL_B];

//do your routine here

}//end I
}//end x
} //end y

for(int x = 0; x < nWidth; x++)
{
for(int y = 0; y < nHeight; y++)
{
for(int i = max(0, y - size); i <= MIN(nHeight – 1, y + size); i++)
{
red = pBGRA_in[(x + i * nWidth) * 4 + CHANNEL_R];
green = pBGRA_in[(x + i * nWidth) * 4 + CHANNEL_G];
blue = pBGRA_in[(x + i * nWidth) * 4 + CHANNEL_B];
}//end I
}//end y
}//end x

The difference here is separability in the kernels. If you can break your routine to use 2 passes rather than the 2d routine, it will always run faster.



JEL wrote:Hi Andy, I have a question I think you're the only one here who can answer :)

I've been over your SDK guide, but couldn't find what I was looking for. And I'm not good enough friends with CPP to be able to figure it out myself.

I have an image... a bayer-mosaic (a raw-file that hasn't been debayered/demosaiced).

This image is made up of 2x2 squares, with 1 red, 1 blue, and 2 green pixels. They are placed in the same order in each 2x2 square.

My goal is to have a script in the script node that can take the red and copy it to the 3 other pixels in its square, and take the blue and copy that to the 3 other pixels, and take the 2 greens and average them and then copy them to the 2 other pixels (or just take 1 green and treat the same way as done with the red and blue)
Am I making sense?

My problem is that I can't figure out how to read such 2x2 squares. I can figure out how to read single pixels, but not these... I guess they're called... bi-cubic squares.

I've attached a crop of one such bayer-mosaic.

The point of it all is to be able to attempt my own routines at demosaicing.

I imagine you already know how to look at adjacent pixels, since I guess that's needed for your denoise/blur plugins, so is this something you will include in your SDK guide?
Thanks

Post Reply