I'm not sure what you mean by "engage porosity into the image", but "...so I started with a simple x,y loop" is almost certainly why it is so slow. If you are doing image processing with a Perl loop, pulling individual pixel values into and out of a PDL, it will be at least 100x slower than doing the same job with the threading engine.

Since you mention trying to select stuff from a range in color space, here's a simple example. Here I assume your image is arranged in (X, Y, RGB) format -- i.e. the dimensions are WxHx3, as would be returned by rim().

$im = rim("myimage.png"); # or whatever -- get your image into a variable
  $color = pdl(128,200,128); # light green for 8-bit RGB

  #####
  # Generate a list of all pixels with a certain color
  $imt = $im->mv(2,0);      # (RGB, X, Y)
$mask = all($imt==$color); # (X, Y) mask -- collapsed over RGB dimension $wh_exact = $mask->whichND; # (2 x N) -- coordinates of all matching points

  #####
# Generate a list of all pixels within a 3-D "slop distance" in RGB space
  # of a certain color
  $slop = 7;
$dist_sq = (($im-$color)*($im-$color))->sumover; # (X,Y) distance image -- collapsed over RGB $mask = ($dist_sq <= $slop*$slop); # mask of matching pixels $wh_sloppy = $mask->whichND; # (2 x M) -- coordinates of all matching points

Does that help?



On May 6, 2011, at 10:01 AM, Luca Cappelletti wrote:

Hello *
I've a performance problem using a simple scan line flood fill image with perl. With 800x600 colour pictures coming from SEM microanalisys I would like to engage porosity into the image so I started with a simple x,y loop. The problem here is that requires too much seconds to scan and produce the new colored image.
At the moment I use imlib2 to read and write pixel color.

I'm new to PDL and I cannot believe that it's true...it's so powerful!!

I don't how can I use PDL to speed up my scan.
Do you know how to flood fill images or count porosity, engage color range and so on?

I can use boolean intersection between 2 sets, the firs my picture the second a color mask but this close to 1 color, I've a range to parse because I have to take into account the error (like the fuzzy option in magickperl floodfill), that will be: my picked pixel color +/- error range so I don't understand how to use matrix solution.

May you help me please?

Thank you in advance,

Luca
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl


_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to