Difference between revisions of "User talk:BytePilot"

From London Hackspace Wiki
Jump to navigation Jump to search
(Replaced content with "hi - what settings did you use for the test cake image? i didn't get the chance to do any other other night as the laser was screwed - so that's so far the only test image we…")
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
well I've done that, but the output is not what we want.
+
hi - what settings did you use for the test cake image? i didn't get the chance to do any other other night as the laser was screwed - so that's so far the only test image we have.  
  
http://hack.rs/cgi-bin/threshold_bitwise.pl
+
you think it needs less power?
  
<pre>
+
is the combined-layers file on the laser's pc?
  
#!/usr/bin/perl -w
+
--[[User:AndyE|AndyE]] 18:37, 16 January 2011 (UTC)
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;
 
 
 
</pre>
 
 
 
I tried doing just the "-operator ALL AND $n" part by itself, it didn't seem to do anything...
 
 
 
--[[User:AndyE|AndyE]] 14:16, 12 January 2011 (UTC)
 
 
 
Possible sytax error ?
 
 
 
<pre>
 
                  "convert", "-type", "grayscale", "-colors", 256, "-operator", "ALL AND $n", "-threshold", $n-1,
 
</pre>
 
Should perhaps be
 
<pre>
 
                  "convert", "-type", "grayscale", "-colors", 256, "-operator", "ALL AND", $n, "-threshold", $n-1,
 
</pre>
 
?
 
 
 
<hr>
 
 
 
yes - seems to need to be "All", "And", "Whatever". Still, here's one that kinds does what we want...
 
 
 
http://hack.rs/cgi-bin/threshold_grayscale.pl
 
 
 
<pre>
 
 
 
#!/usr/bin/perl -w
 
use strict;
 
use CGI;
 
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
 
use List::Util qw(max min);
 
 
 
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 ** (8 + $i)) / 2**16 )*100; #as a percentage
 
 
 
        my @ar = ("gm",
 
                  # "convert", "-type", "grayscale", "-colors", 8, "-threshold", 12.5*$i ."%",
 
                  "convert", "-type", "grayscale", "-operator",
 
                    "Gray", "And", $n  ."%",
 
                    "-threshold", max($n -1, 0) ."%",
 
                  $tempfile,
 
                  "/var/www/threshold_output/$filename".$i );
 
 
 
        print $q->p("$i : " . 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;
 
 
 
 
 
 
 
</pre>
 
 
 
i converted the raw values to percentages of a max because it wasn't working the other way. I'm not clear on the bit depth of the greyscale image. tried setting it with -depth but still no joy. still, this version is kind of working as it is.
 
 
 
--[[User:AndyE|AndyE]] 15:12, 12 January 2011 (UTC)
 
 
 
 
 
 
 
it might be better if, rather than laz0ring the same location multiple times, we converted the image to 8 shades of grey and then picked out each shade as a seperate layer with it's own power settings. that's what i was starting to try to do in the commented-out bit above - not sure how to pick out each shade.
 
 
 
probably worth experimenting with both methods on the laser cutter
 
 
 
--[[User:AndyE|AndyE]] 15:20, 12 January 2011 (UTC)
 

Latest revision as of 18:37, 16 January 2011

hi - what settings did you use for the test cake image? i didn't get the chance to do any other other night as the laser was screwed - so that's so far the only test image we have.

you think it needs less power?

is the combined-layers file on the laser's pc?

--AndyE 18:37, 16 January 2011 (UTC)