Hi again:

Ignore that last post. I missed the line where

   my($a) = $in->(0:$d)->copy - $opt->{post};
  ...
   $out->(0:$d) .= $a x $opt->{inverse} - $opt->{pre};

I'm still working on it...
--greg


Greg Ederer wrote:
Hi All:

The flags seem to be a non-issue. I am looking inside of PDL::Transform.pm and am wondering about some things:

First, since I'm relatively new to matrix manipulation with PDL, I expanded the "map" function to match Craig's description of what it is supposed to do, and removed all the options so I wouldn't get confused. Here's the transform part:

 ##############################
 ## Rubber meets the road: calculate the inverse transformed points.
 my $ndc = PDL::Basic::ndcoords(@dd);
my $idx = $ndc->double + 0.5; # shift from pixel corner to pixel center $idx = PDL::Transform::t_fits($out)->apply($idx); # output [col,row] => output scientific $idx = $me->invert($idx); # output scientific => input scientific $idx = PDL::Transform::t_fits($in)->invert($idx); # input scientific => input [col,row] $a = $in->interpND($idx,{method=>'s', bound=>'t'}); # interpolate values at [col,row]
 $out->slice(':') .= $a; # trivial slice prevents header overwrite...
 return $out;
########################

What I find is that the results of each transform stage look OK until I get to the line $idx = PDL::Transform::t_fits($in)->invert($idx); # input scientific to input [col,row]

The resulting idx matrix has [col,row] that are not scaled correctly. So I went and looked at the "t_fits" definition, which I see is a subclass of "t_linear", which defines the following functions :

     $me->{func} = sub {
       .....
       $out->(0:$d) .= $a x $opt->{matrix} + $opt->{post};
       return $out;
     };

and

     $me->{inv} = sub {
     ....
       $out->(0:$d) .= $a x $opt->{inverse} - $opt->{pre};
       $out;
     }

and my question is, shouldn't the inverse be defined as

       $out->(0:$d) .= ($a - $opt->{pre}) x $opt->{inverse};

Again, my matrix math is rusty, but for a line,
   y = mx + b;
so
 x=(y-b) / m;

I haven't had time to try this yet, but please correct me if I'm barking up the wrong tree.

Thanks,
--greg



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

Reply via email to