On 1/7/2011 8:26 PM, Narendra Sisodiya wrote:
    If you need more math, numpy can help. Somethign like:

    a = np.asarray(PIL_image)
    background_color = 0
    rows, cols = np.where(a <> background_color) # background color a uint32
    BB = (rows.min(), rows.max(), cols.min(), cols.max())

I am unable to get what that code means ?
May you explain how I can use above code with getbbox ? Or the above
code using NumPy is alternate of getbbox method ?

It's an alternative.

IF yes, then which will be the faster ?

The only way to know is to try it, but I suspect the PIL getbox() is a bit faster, as I image it does it all in one C loop. numpy is doing it in a couple loops.

The reason to use numpy is if you want to do something more complex that is not directly supported by PIL.

you might want to look at the scip ndimage toolbox it has some useful stuff:

http://www.scipy.org/SciPyPackages/Ndimage

though perhaps you've solved you problem.

-Chris


--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

chris.bar...@noaa.gov
_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to