Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: How can I tranlate imread and imshow matlab function into perl

by kevbot (Priest)
on May 14, 2016 at 05:22 UTC ( #1163020=note: print w/replies, xml ) Need Help??


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:
  • Comment on Re: How can I tranlate imread and imshow matlab function into perl
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1163020]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2017-10-21 00:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (268 votes). Check out past polls.

    Notices?