CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
difference of two images

 



thegreatonech
New User

Jun 11, 2010, 2:24 AM

Post #1 of 2 (671 views)
difference of two images Can't Post

Hallo,

I have two grayscale pictures (same size (1024,768), grayscale from 0 to 255). I want to take the difference of this two pictures. (difference of the grayscale values for each pixel)
I tried something but there's an error:
gd-png: fatal libpng error: Invalid number of colors in palette
gd-png error: setjmp returns error condition

here the code:

Code
use GD::Image; 


# create a new image
$im = new GD::Image(1024,768);


$bildin= "img/CH_IR039/05100100.039";
$bildout= "img/CH_IR039/05100100.png";

$bildin2= "img/CH_IR108/05100100.108";
$bildout2= "img/CH_IR108/05100100.png";

$befehl = "convert ".$bildin." ".$bildout;
system($befehl);
$befehl2 = "convert ".$bildin2." ".$bildout2;
system($befehl2);

$myImage = GD::Image->newFromPng($bildout);

$myImage2 = GD::Image->newFromPng($bildout2);



$k=0;
for ($x=0 ; $x<=1023; $x++) {
for ($y=0 ; $y<=767; $y++)
{
$index = $myImage->getPixel($x,$y);
$index2 = $myImage2->getPixel($x,$y);

($Image1,$dummy1,$dummy1) = $myImage->rgb($index); #Achtung evt. $red[]
($Image2,$dummy1,$dummy1) = $myImage2->rgb($index2);

$color = abs($Image-$Image2);

$im->setPixel($x,$y,$color);

$k++;
}
}

open(PICTURE, ">picture.png") or die("Cannot open file for writing");


binmode PICTURE;


print PICTURE $im->png;

close PICTURE;

may be you can help me

thanks


Bianca
User

Jun 11, 2010, 5:09 AM

Post #2 of 2 (665 views)
Re: [thegreatonech] difference of two images [In reply to] Can't Post

Crosspost: http://www.perl-community.de/bat/poard/thread/15126


(This post was edited by Bianca on Jun 11, 2010, 5:11 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives