3 ms·
What sort of "graphics" are you looking for? I generally use Numpy NDarrays and Scipy's NDimage functions for graphics & image processing in Python. Aside fro
by jboy 12y ago
What sort of "graphics" are you looking for?
I generally use Numpy NDarrays and Scipy's NDimage functions for graphics & image processing in Python. Aside from the NDarray data-structure itself, there's almost no O-O; everything in Numpy is either a method of this one workhorse data-type, or module-level functions that operate upon this data-type.
NDarrays are great because they can represent all of:
- images (using 2-D arrays for binary or greyscale images, and 3-D arrays for colour images);
- the vectors & matrices used in 3-D computer graphics;
- the masks used in spatial image filtering;
- the "structuring elements" used in morphological image processing.
Once you get used to the syntax, NDarray indexing & slicing are very efficient in both keystrokes & CPU cycles to get/set the values of pixels or arbitrary rectangular regions.
NDarray methods & the related Numpy functions offer element-wise operations (like pixel-wise Boolean logical ops, or "square every element in the matrix" / "square-root every element in the matrix" as part of the Euclidean distance calculation) and operations that can run over any dimension of the image (including the colour dimension, which is useful for calculations like the N-dimensional sum in dot-products or Euclidean distance). And the for-loops are in C, so they're blindingly fast.
NDimage functions provide filters and morphological processing capabilities. Plus, Numpy integrates nicely with Matplotlib so you can display images and plot histograms.