To do pseudocolor lookups, do this:

$im=rim($grayscalefile);
$lut=cat(xvals(256),255+zeroes(256),zeroes(256)); #or whatever -- 256x3

$rgb= $lut->indexND( $im->(*1) ); # or $im->dummy(1,1)



the output should end up WxHx3. 

(mobile)


On Aug 30, 2010, at 9:28 PM, Craig DeForest <[email protected]> wrote:

> You should be using range() or indexND rather than index. The latter only 
> works well on 1-d lookups.  More later.
> 
> (Mobile)
> 
> 
> On Aug 30, 2010, at 6:49 PM, P Kishor <[email protected]> wrote:
> 
>> On Mon, Aug 30, 2010 at 7:02 PM, Chris Marshall <[email protected]> wrote:
>>> On 8/30/2010 7:00 PM, P Kishor wrote:
>>>> On Mon, Aug 30, 2010 at 2:39 PM, P Kishor<[email protected]>  wrote:
>>>>> This is driving me nuts...
>>>>> 
>>>>> print "Info for lut : " . $lu->info . "\n";
>>>>> print "Info for year: " . $yr->info . "\n";
>>>>> $ypdl->wpic("model_output/$file", {LUT =>  $lut});
>>>>> 
>>>>> prints...
>>>>> 
>>>>> 
>>>>> Info for lut : PDL: Byte D [3,256]
>>>>> Info for year: PDL: Byte D [252,189]
>>>>> PDL::index: invalid index -2147483648 (valid range 0..255) at
>>>>> /usr/local/lib/perl5/site_perl/5.12.1/darwin-2level/PDL/ImageRGB.pm
>>>>> line 147.
>>> 
>>> First, the piddle you are writing as an image is
>>> not the piddle you are listing information about.
>>> It is not possible for a byte value to be -2147483648.
>>> I suggest writing a small test script and trace it
>>> under the debugger to see what is going on.  Maybe
>>> something is not what you think it is.
>>> 
>> 
>> 
>> Unfortunately, I don't know how to use the debugger, but I did write a
>> test script. With the help of Craig's bigstring() sub, I get the
>> following --
>> 
>> ------------
>> print "In my program\n" . "=" x 50 . "\n";
>> print "Info for piddle pdl: " . $pdl->info . "\n";
>> print bigstring($pdl,"%3g") . "\n";
>> 
>> 
>> 
>> my $foo = $lut->xchg(0,1);
>> 
>> print "Info for piddle foo: " . $foo->info . "\n";
>> print $foo . "\n";
>> 
>> 
>> 
>> my $bar = $pdl->dummy(0);
>> 
>> print "Info for piddle bar: " . $bar->info . "\n";
>> print bigstring($bar,"%3g") . "\n";
>> 
>> 
>> 
>> my $res = index($foo, $bar);
>> 
>> print "Info for piddle res0: " . $res->info . "\n";
>> print bigstring($res,"%3g") . "\n";
>> ------------
>> 
>> 
>> In my program
>> ==================================================
>> Info for piddle pdl: PDL: Byte D [252,189]
>> [
>> [   0   0   0   ..   0 ]
>> [   0   0   0   ..   0 ]
>> [   0   0   0   ..   0 ]
>> ..
>> ]
>> Info for piddle foo: PDL: Byte D [256,3]
>> 
>> [
>> [  0   1   2   3 .. 255]
>> [255 255 255 255 .. 255]
>> [  0   0   0   0 ..   0]
>> ]
>> 
>> Info for piddle bar: PDL: Byte D [1,252,189]
>> [
>> [
>> [   0 ]
>> ..
>> ]
>> ]
>> Info for piddle res: PDL: Byte D [3,252,189]
>> PDL::index: invalid index -2147483648 (valid range 0..255) at
>> /usr/local/lib/perl5/site_perl/5.12.1/darwin-2level/PDL/Core.pm line
>> 2408.
>> 
>> 
>> 
>> There is something wrong with $res created with index($lut, $bar), and
>> I don't quite know what to do. This has become a show-stopper for me
>> as I have to use lookup tables to create color images. The program
>> works just fine, and images are created just fine if I don't use a
>> LUT. Is there something wrong with my LUT? After a day of struggling
>> with this, I am at a loss.
>> 
>> 
>>> --Chris
>>> 
>>>>> As far as I can see, $yr has nothing funky in it. I used Craig's
>>>>> bigstring method to print out the bighonkingpdl, and it is mostly a
>>>>> bunch of zeroes.
>>> 
>> 
>> 
>> 
>> 
>> 
>> -- 
>> Puneet Kishor http://www.punkish.org
>> Carbon Model http://carbonmodel.org
>> Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
>> Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
>> Nelson Institute, UW-Madison http://www.nelson.wisc.edu
>> -----------------------------------------------------------------------
>> Assertions are politics; backing up assertions with evidence is science
>> =======================================================================
>> 
>> _______________________________________________
>> Perldl mailing list
>> [email protected]
>> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>> 
> 

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to