http://www.perlmonks.org?node_id=1163020


in reply to How can I tranlate imread and imshow matlab function into perl

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: