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.


Edit:

Monk vr provided the solution in his replies. Very thankful for his responses.

Updated question

How to rescale a 2-dimensional data by interpolation, using piddles?

Solution
use 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.


In reply to Interpolating data using pdl by karthik248

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.