[SciPy-dev] PIL and sparse matrices?

Robert Cimrman cimrman3 at ntc.zcu.cz
Thu Nov 2 06:16:56 EST 2006


Bill Baxter wrote:
>>> From what I understand PIL images are basically stored as a list of
>>> pointers
> to rows of data.  It's a good way to do it if you want to manipulate images
> so big that you become unlikely to be able to allocate that much contiguous
> free space.
> It seems to me that CSR sparse matrices are pretty similar in structure,
> just with the addition of a list of indices per row.  Perhaps the same
> machinery could be dumbed down a bit to allow for PIL image data to be
> handled directly in SciPy.  Perhaps a "UDR" format (uncompressed dense
> row)?
> 
> Just a thought.
> --bb

There is no problem in adding new sparse matrix type, but what would you
like to use it for? As it is now, the sparse matrix module is good for
solving large sparse systems of linear equations. The other modules of
SciPy/NumPy do not work with sparse matrices (as they do not understand
their format - spmatrix does not inherit from ndarray, it is a separate
composite class) and so to use them you would have to convert the image
to a regular dense array anyway (IMHO).

r.



More information about the SciPy-Dev mailing list