Archive - Jan 14, 2007

Date

First release of image rgb arithmetic class

Image arithmetics allow math operations to be done to 2 or more images. Here is a class does addition, subtraction, difference, average, min, max, multiplication, amplitude, AND, OR and XOR functions to 2 png images and out put the result.
This is the first release, version 0.1, very limited function indeed. It only can do arithmetic on RGB , which does not include transparency. There might be a update which make it support HSL and HSV.
I will show some example of what it can do

First, the original 2 images:
Input Image 1 Input Image 2
Each snippet start with

$cool = new image_rgb_arithmetic(50, 50);
$cool->add_image('inputimage1.png');
$cool->add_image('inputimage2.png');

end with

$cool->output();

down here only list the operation between them.

Here is the result of each snippet:
Addition

$cool->image_sum();

Image Sum

Subtraction

$cool->image_sub();

Image Sub

Difference

$cool->image_difference();

Image Difference

Average

$cool->image_average();

Image Average

Minimal

$cool->image_min();

Image Minimal

Maximum

$cool->image_max();

Image Maximum

Multiplication

$cool->image_product();

Image Multiplication

Amplitude

$cool->image_amplitude();

Image Amplitude

AND/OR/XOR

$cool->image_and();

Image AND

$cool->image_or();

Image OR

$cool->image_xor();

Image XOR

Image Arithmetic Class

PHP implementation of Dropsort

PHP implementation of Dropsort, a lossy sort algorithm that will drop anything that is smaller than the previous item.

function dropsort($array){
	$i = 0;
	while($array[$i]){
		if($array[$i] <= $array[$i+1]||!isset($array[$i+1])){
			++$i;
		}else{
			array_splice($array, $i+1, 1);
		}
	}
	return $array;
}

Editor Comment:

After making the Intelligent Design Sort work in PHP, this is another esoteric algorithm I implant in PHP. I guess I will make all the esoteric algorithms featured in DM's Esoteric Programming Languages work in PHP

Honey Pot that kill bots