Hey guys, come check out this webpage I made, I'd like some input

notfred

Lifer
Feb 12, 2001
38,241
4
0
ok, I really don't care about input on the page. I put it together in 30 seconds. What I want input on is what's on the page. What do you think of the quality of the images I'm generating? they look pretty good? Better than the "nearest neighbor" stuff at the very least? What do you think of the quality?

here's the link
 

Rallispec

Lifer
Jul 26, 2001
12,375
10
81
wow!

thats really cool. looks really good if you ask me. I wouldnt even know wehre to begin doing something like that. what language did you write the algorithm in?
 

AdamDuritz99

Diamond Member
Mar 26, 2000
3,233
0
71
oh man, could i please see the source code of that? That's very very cool!!!!

great coding!


peace
sean
 

ddjkdg

Senior member
Dec 22, 2001
718
0
0
Looks good. You can definitely notice the better quality on the blow up, but the difference on the shrunken down pics is incredible.
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
Originally posted by: WarCon
How many passes?

1, slow, careful pass :)

Originally posted by: AdamDuritz99
oh man, could i please see the source code of that? That's very very cool!!!!?

I guess so, it's not real pretty yet, and it runs slow, but I'll post it in a minute.

keep in mind that I've just started on this project :)
 

AdamDuritz99

Diamond Member
Mar 26, 2000
3,233
0
71
Originally posted by: ddjkdg
Looks good. You can definitely notice the better quality on the blow up, but the difference on the shrunken down pics is incredible.

The pixel replication is definintely awesome. His pixel deletion is great in my opinion for overall quality. But if you look at the rocks with his algorithm, they look blurier.
Just my honest opinion....

Again great job!


peace
sean
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
The current source code:

#!/usr/bin/perl-w

#Copyright2002TylerKaraszewski

#final_sizeisthewidthofthethumbnail
$final_size=$ARGV[0];
#qualityisthejpegqualityforoutput.intfrom0to100.
$quality=$ARGV[1];
#image_nameisthenameoftheimagetoopen
$image_name=$ARGV[2];

#openstheoriginal,andputsthedatato"$imagedata"
open(START,"$image_name");
while(<START>){$imagedata.=$_}
close(START);

#thisprogramrequirestheGD.pmperlmodule.
useGD;

#createsaGDimagefrom"$imagedata"
$original=GD::Image->new("$imagedata");

#getstheoriginalimageswidthandheight,andstoresthemin"$orig_width"and"$orig_height",respectively
($orig_width,$orig_height)=$original->getBounds();

#determinestheaspectratiooftheoriginalimageandstoresthatvalueasaflotingpointnumberin"$aspect_ratio"
$aspect_ratio=$orig_height/$orig_width;

#storesthewidthandheightofthethumbnailin"$new_width"and"$new_height",respectively
$new_width=$final_size;
$new_height=int($aspect_ratio*$new_width);

#determinethenumberofpixelsintheoriginalperpixelinthethumbnail.
$pixel_ratio=$orig_width/$new_width;

#createsthethumbnailimageinthecorrectsize,andsetsthe(256color)palleteappropraitely.
$thumb2=newGD::Image($new_width,$new_height);
$thumb2->copyResized($original,0,0,0,0,$new_width,$new_height,$orig_width,$orig_height);

#printtheimagewithizechangedbypixelreplication/deletion,forcomparison.
open(THUMB,">thumb2_$image_name");
printTHUMB$thumb2->jpeg($quality);
close(THUMB);

#checktoseewhichagorithmtouse,andstartthecorrectone.
if($pixel_ratio>2){

#offsetisforcenteringtheresizealgorithmonthepixeltobeoperatedon
$offset=$pixel_ratio/2;

#beginstheiterationhorizontallyacrosstheimage(lefttoright).
for(my$i=0;$i<$new_width;$i++){
#for(my$i=0;$i<16;$i++){

#beginstheiterationverticallydowntheimage.
for(my$j=0;$j<$new_height;$j++){
#for(my$j=0;$j<14;$j++){

#determineoriginalpixelvaluestosamplefrom
my$x_value=(($i/$new_width)*$orig_width+$offset);
my$y_value=(($j/$new_height)*$orig_height+$offset);

#Determinethepixelsthatweareusingfromtheoriginalimage
my$start_x=int($x_value-$offset);
my$start_y=int($y_value-$offset);
my$end_x=int($x_value+$offset);
my$end_y=int($y_value+$offset);

my@r;
my@g;
my@b;
my@d;

my$count_x=0;
for(my$k=$start_x;$k<=$end_x;$k++){
my$count_y=0;
for(my$l=$start_y;$l<=$end_y;$l++){
my$temp=$original->getPixel(int($start_x+$count_x),int($start_y+$count_y));
(my$r,my$g,my$b)=$original->rgb($temp);
push@r,$r;
push@g,$g;
push@b,$b;
$count_y++;
}
$count_x++;
}

my$red=0;
foreach$value(@r){$red+=$value/$#r}
$red=int($red);

my$green=0;
foreach$value(@g){$green+=$value/$#g}
$green=int($green);

my$blue=0;
foreach$value(@b){$blue+=$value/$#b}
$blue=int($blue);

#Determeinetheclosestcolorinthepallettetothecolorwefound.
my$pixel=$thumb2->colorClosest($red,$green,$blue);
#Andsetthepixelinthethumbnailtothatcolor.
$thumb2->setPixel($i,$j,$pixel);
}
}
}else{

#beginstheiterationhorizontallyacrosstheimage(lefttoright).
for(my$i=0;$i<$new_width;$i++){
#for(my$i=0;$i<16;$i++){

#beginstheiterationverticallydowntheimage.
for(my$j=0;$j<$new_height;$j++){
#for(my$j=0;$j<14;$j++){

#determineoriginalpixelvaluestosamplefrom
my$x_value=(($i/$new_width)*$orig_width);
my$y_value=(($j/$new_height)*$orig_height);

#DetermineweightedvaluesforXandY
#Note:l,r,t,andbdenoteleft,right,topandbottom
my$weight_l=$x_value-int($x_value);
my$weight_t=$y_value-int($y_value);
my$weight_r=1-$weight_l;
my$weight_b=1-$weight_t;

#Determinethepixelsthatweareusingfromtheoriginalimage
my$start_x=int($x_value);
my$start_y=int($y_value);

#gettheRBGvaluesofthepixelsthatwe'reusingfromtheoriginalimage
#andstoretheminsomevariables.
my$temp1=$original->getPixel($start_x,$start_y);
(my$r_lt,my$g_lt,my$b_lt)=$original->rgb($temp1);
my$temp2=$original->getPixel($start_x+1,$start_y);
(my$r_rt,my$g_rt,my$b_rt)=$original->rgb($temp2);
my$temp3=$original->getPixel($start_x,$start_y+1);
(my$r_lb,my$g_lb,my$b_lb)=$original->rgb($temp3);
my$temp4=$original->getPixel($start_x+1,$start_y+1);
(my$r_rb,my$g_rb,my$b_rb)=$original->rgb($temp4);

#Computefinalvaluesforthenewpixelbasedonthevalueswecollected

my$red=int($weight_l*$weight_t*$r_rb+$weight_r*$weight_t*$r_lb+$weight_l*$weight_b*$r_rt+$weight_r*$weight_b*$r_lt);

my$green=int($weight_l*$weight_t*$g_rb+$weight_r*$weight_t*$g_lb+$weight_l*$weight_b*$g_rt+$weight_r*$weight_b*$g_lt);

my$blue=int($weight_l*$weight_t*$b_rb+$weight_r*$weight_t*$b_lb+$weight_l*$weight_b*$b_rt+$weight_r*$weight_b*$b_lt);

#Determeinetheclosestcolorinthepallettetothecolorwefound.
my$pixel=$thumb2->colorClosest($red,$green,$blue);
#Andsetthepixelinthethumbnailtothatcolor.
$thumb2->setPixel($i,$j,$pixel);
}
}
}

open(THUMB,">thumb_$image_name");
printTHUMB$thumb2->jpeg($quality);
close(THUMB);

print"finished\n";
 

DanFungus

Diamond Member
Jul 27, 2001
5,857
0
0
what the HELL do I do with the source code?

<--not a programmer...at all
(but the pictures look awesome with your code!)
 

gopunk

Lifer
Jul 7, 2001
29,239
2
0
Originally posted by: DanFungus
what the HELL do I do with the source code?

<--not a programmer...at all
(but the pictures look awesome with your code!)

you can put it on a computer with perl installed and run it :)
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
Originally posted by: DanFungus
what the HELL do I do with the source code?

<--not a programmer...at all
(but the pictures look awesome with your code!)

AdamDuritz99 wanted to see it, so I posted it. You probably wont do anything with it. If you wanted, you could try and run it, but I don't even know if it's possible on windows (are the GD libraries available for windows? I guess you could compile them if they're not...)

Anyway, thanks for the compliment :)
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
oh, and if anyone does try to run it, remember to replace the smileyface with a closing parenthesis. (just the ")", no semicolon)
 

DanFungus

Diamond Member
Jul 27, 2001
5,857
0
0
as homer simpsons says.....Doh! Doh!

Well, at least I was enlightened on what to do with it.....but, alas, I have windows.

(bump ;))
 

benliong

Golden Member
Jun 25, 2000
1,153
0
0
very nice use of weights on top bottom left and right of original pixel values. :)

the code is well documented too. very nice.
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
Originally posted by: DanFungus
as homer simpsons says.....Doh! Doh!

Well, at least I was enlightened on what to do with it.....but, alas, I have windows.

(bump ;))

You could always go and look and see if you could find GD for windows :)