User talk:BytePilot
Revision as of 14:57, 12 January 2011 by 83.244.216.18 (talk)
well I've done that, but the output is not what we want.
http://hack.rs/cgi-bin/threshold_bitwise.pl
#!/usr/bin/perl -w use strict; use CGI; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); my $q = CGI->new(); print $q->header; print $q->start_html; print $q->p("this is a thing for doing threshholding"); print $q->p("<small>or possibly <i>thresholding</i>?</small>"); print $q->start_form( -enctype => "multipart/form-data" ); print $q->p("file"); print $q->filefield('uploaded_file'); print $q->submit(); print $q->end_form; # do we have an upload? my $filehandle = $q->upload('uploaded_file'); if (defined $filehandle) { # do shit print $q->p("I'm doing shit"); # no, actually do shit my $filename = $q->param('uploaded_file'); my $tempfile = $q->tmpFileName($filename); foreach my $i (0 .. 7) { my $n = 2 ** ($i + 8); my @ar = ("gm", "convert", "-type", "grayscale", "-colors", 256, "-operator", "ALL AND $n", "-threshold", $n-1, $tempfile, "/var/www/threshold_output/$filename".$i ); print $q->p("$i : $n : " . join " ", @ar); system(@ar) == 0 or carp "system call failed: $?"; #safer than passing a string to system() print $q->img({src => "/threshold_output/$filename".$i}); } } print $q->end_html;
I tried doing just the "-operator ALL AND $n" part by itself, it didn't seem to do anything...
--AndyE 14:16, 12 January 2011 (UTC)
Possible sytax error ?
"convert", "-type", "grayscale", "-colors", 256, "-operator", "ALL AND $n", "-threshold", $n-1,
Should perhaps be
"convert", "-type", "grayscale", "-colors", 256, "-operator", "ALL AND", $n, "-threshold", $n-1,
?