#!/usr/bin/perl use warnings; use strict; use LWP::Simple; use PDL; use PDL::Graphics::PGPLOT; # getting a brain image from the ITK (http://itk.org) CVS website my $img_url = "http://www.itk.org/cgi-bin/viewcvs.cgi/*checkout*/Examples/Data/BrainProtonDensitySliceBorder20.png?rev=1.2&root=Insight"; my $savefilename = "brain.png"; my $status = getstore($img_url,$savefilename); print $status."\n" if is_success($status); # reading the image and creating a copy of it $brain = rim( “brain.png” ); $brain2 = $brain->copy; #plotting the two images in two different windows $dev = '/XSERVE'; $win = PDL::Graphics::PGPLOT::Window->new( { Dev => $dev } ); $win->imag( $brain ); $win2 = PDL::Graphics::PGPLOT::Window->new( { Dev => $dev } ); $win2->imag( $brain2 ); # The pixel values in the images are in the range [0, 255] # (with zero representing black and 255 representing white). # # Let's change all the pixel values greater than 220 to be # equal to zero. This will create some black spots in the # image $indx = which( $brain > 220 ); $brain2->flat->index( $indx ) .= 0; # Let's plot the new image $win2->imag( $brain2 ); # Now, we free up the windows so that you can close them. $win->close(); $win2->close();