karthik248 has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks,
I'm new to perl, as well as PDL. So here's the question..
I have a matrix of size 1800x1800, and only few points have valid data(say 10000). Now, i want to interpolate(bilinear) whole matrix using the available data.
I've already implemented this using pure-perl, but due to complexity issues, i'm trying to do this using PDL
I have a few ideas in mind, but i'm too sure about them, as i don't know if i can implement the same using PDL.
Any suggestions or solutions are appreciated. Thanks in advance.
Monk vr provided the solution in his replies. Very thankful for his responses.
Updated questionHow to rescale a 2-dimensional data by interpolation, using piddles?
Solutionuse PDL; use PDL::Image2D; use PDL::IO::GD; my $data_pdl; #a pdl(289,145) my $interpolated_pdl = zeroes(21600,10800); bilin2n($interpolated_pdl,$data_pdl); my $range1 = ( $x >= 5 ) * ( $x < 10 ); my $range2 = ( $x >= 10 ) * ( $x < 15 ); my $range3 = $x >= 15; my $plotted_pdl = ( $range1 + 2 * $range2 + 3 * $range3 )-> byte; my $palette = byte [ [ 0, 0, 0 ], [ 255, 0, 0 ], [ 0, 255, 0 ], [ 0, 0, 255 ] ]; my $plotted_image = PDL::IO::Image->new_from_pdl($plotted_pdl,$pal +lete); my $gd_image=PDL::IO::GD->new(pdl=>$plotted_image->pixels_to_pdl); #now all kinds of GD operations can be applied.
I'm sure there are much better ways of doing this, like directly generating a PDL::IO::GD object using PDL::IO::GD->new({ pdl => $pdl_var, lut => $lut_piddle }) but the above solution works fine.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Interpolating data using pdl
by vr (Curate) on Mar 15, 2017 at 11:56 UTC | |
by karthik248 (Acolyte) on Mar 15, 2017 at 16:35 UTC | |
by vr (Curate) on Mar 15, 2017 at 17:11 UTC | |
by karthik248 (Acolyte) on Mar 15, 2017 at 17:53 UTC | |
by vr (Curate) on Mar 15, 2017 at 19:43 UTC | |
| |
Re: Interpolating data using pdl
by thanos1983 (Parson) on Mar 15, 2017 at 10:41 UTC | |
by karthik248 (Acolyte) on Mar 15, 2017 at 11:27 UTC | |
Re: Interpolating data using pdl
by vrk (Chaplain) on Mar 15, 2017 at 09:46 UTC | |
by karthik248 (Acolyte) on Mar 15, 2017 at 10:10 UTC | |
by thanos1983 (Parson) on Mar 15, 2017 at 11:46 UTC |