Luca - Dumb question... is sem.jpg the name of the image file you're trying to open?
David On Tue, May 10, 2011 at 2:54 AM, Luca Cappelletti <[email protected]> wrote: > Hello Craig, > > first thank you for your answer you enlight me about using direct matrix > manipulation vs old style raw looping. > Seems that your snippets is quiet clear now for me but the point is that > when I try to run it, it faults against some tmp file that cannot be created > under Linux. > > I did a raw test here with your code...but due to my low skill I produced an > error that I do not recognize: > > #!/usr/bin/env perl > > package PDL::IO::Pic; > use PDL; > use strict; > > my $im = rim("sem.jpg"); # or whatever -- get your image into a > variable > my $color = pdl(128,200,128); # light green for 8-bit RGB > > ##### > # Generate a list of all pixels with a certain color > my $imt = $im->mv(2,0); # (RGB, X, Y) > my $mask = all($imt==$color); # (X, Y) mask -- collapsed over RGB > dimension > my $wh_exact = $mask->whichND; # (2 x N) -- coordinates of all matching > points > > > > ##### > # Generate a list of all pixels within a 3-D "slop distance" in RGB > space > # of a certain color > my $slop = 7; > my $dist_sq = (($im-$color)*($im-$color))->sumover; # (X,Y) distance > image -- collapsed over RGB > $mask = ($dist_sq <= $slop*$slop); # mask of matching > pixels > my $wh_sloppy = $mask->whichND; # (2 x M) -- coordinates of all matching > points > > > $im->wpic("pippo.png") > > > > I expected that this code simply take sem.jpg and write it into sem.png > without errors > > but my output was: > > linux@linux-desktop:~/Sviluppo/TEST$ ./pdl.pl > PDL: couldn't open tmpfile > Caught at file /usr/lib/perl5/PDL/IO/Pic.pm, line 0, pkg main > Compilation failed in require at (eval 1) line 21, <DATA> line 206. > BEGIN failed--compilation aborted at (eval 1) line 21, <DATA> line 206. > BEGIN failed--compilation aborted at ./pdl.pl line 4, <DATA> line 206. > linux@linux-desktop:~/Sviluppo/TEST$ > > > > What's wrong? > > Thanks for all > > ciao, > > Luca > > > > > > > > > > > > > > > > > > > > > > > -- > --- > Luca Cappelletti > http://developerinfodomestic.blogspot.com > > "...Together we stand, divided we fall." > > .O. > ..O > OOO > > Zeitgeist Activist > > GTalk,MSN: luca <dot> cappelletti <at> gmail <dot> com > FSF Member: #9269 > Linux Registered User: #223411 > Ubuntu Registered User: #7221 > > "l'intelligenza è utile per la sopravvivenza se ci permette di estinguere > una cattiva idea prima che la cattiva idea estingua noi" > > "La chiave di ogni uomo è il suo pensiero. Benché egli possa apparire saldo > e autonomo, ha un criterio cui obbedisce, che è l'idea in base alla quale > classifica tutte le cose. Può essere cambiato solo mostrandogli una nuova > idea che sovrasti la sua" > > "Uno studioso è soltanto un modo in cui una biblioteca crea un’altra > biblioteca " > > _______________________________________________ > Perldl mailing list > [email protected] > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl > > -- Sent via my carrier pigeon. _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
