meemee has asked for the wisdom of the Perl Monks concerning the following question:

I am quite new to perl. I am trying to translate an image processing code which is written in matlab. In matlab, to read and show the image is very simple. The code uses "imread" and "imshow" function to read and display it. Then from the image, using "ginput" function, the code can generate x and y coordinates. I am looking for the same command/function for (imread,imshow, ginput) in perl script. Can anyone suggest me? Thanks.
  • Comment on How can I tranlate imread and imshow matlab function into perl

Replies are listed 'Best First'.
Re: How can I tranlate imread and imshow matlab function into perl
by kevbot (Vicar) on May 14, 2016 at 05:22 UTC

    If you are trying to translate code from Matlab, you might want to take a look at PDL. There is even a guide for MATLAB users.

    Using Prima, I was able to put together a simple app that loads and displays an image. When one clicks on the image, the coordinates are given in a popup message box. This code doesn't use PDL, but if you wanted to process the image in some way before displaying it you would likely find PDL to be useful (and Prima works well with PDL).

    #!/usr/bin/env perl use strict; use warnings; use Prima qw(Application MsgBox ImageViewer); # Example image taken from the "Astronomy Picture of the Day Archive" # http://apod.nasa.gov/apod/archivepix.html # Picture of the day May 13, 2016 # http://apod.nasa.gov/apod/ap160513.html my $im = Prima::Image->load('mercury-transit-2016-50legaultc.jpg'); my $sf = 1.2; # scaling factor my $w = $im->width; # image width my $h = $im->height; # image height my $wDisplay = Prima::MainWindow->create( text => 'Image Viewer', size => [ $sf*$w, $sf*$h ], ); $wDisplay->insert( 'Prima::ImageViewer', size => [ $w, $h ], image => $im, autoZoom => 1, onMouseDown => sub { my ( $self, $button, $mod, $x, $y) = @_; message("You clicked me at: $x:$y!"); } ); run Prima;
    When working with PDL and Prima, it can be a bit difficult to find the correct documentation for a give task (but searching usually pays off!). Here are some links that helped me piece together this code:
Re: How can I tranlate imread and imshow matlab function into perl (tk canvas)
by LanX (Saint) on May 13, 2016 at 23:30 UTC
    Welcome to the monastery! :)

    I don't know Matlab and these functions, but you might be interested searching for perl tk canvas image

    There is plenty of sample code online.

    HTH! =)

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

Re: How can I tranlate imread and imshow matlab function into perl
by stevieb (Canon) on May 13, 2016 at 23:33 UTC

    First, we need to see what you currently have. Your sample data and code should go into <code></code> tags. Second, it would be appreciated if you could show what you've tried.

    We don't do free work here upon request. You need to show at least some effort.

      Come on, you are a bit too harsh, he's basically asking how to show images and plot points in Perl.

      What kind of code can he possibly show?

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

        I feel I'm one of the more lenient and accepting Monks... I often respond with code to even homework questions. In this case, I have no clue what the OP is trying to do. I responded with a generic, typically accepted response to a post that contains no information. Not everyone knows that the post translates into image requirements.