|
From: John H. <jdh...@ac...> - 2004-03-10 20:00:06
|
>>>>> "Perry" == Perry Greenfield <pe...@st...> writes:
Perry> Todd and I just talked about this. There are two possible
Perry> approaches, one of which should work and the other which we
Perry> would have to think about. The simpler approach is to write
Perry> a C extension using the Numeric API. As long as a small,
Perry> rarely-used, subset of the Numeric API is not used (the
Perry> UFunc API and some type conversion stuff in the type
Perry> descriptor)
OK, I'll start with plain vanilla Numeric along the lines Todd sent me
earlier, and we can do the (apparently straightforward)
numarray/numeric port when we have a prototype.
Perry> I agree that this is the drawback. On the other hand,
Perry> processor memory has grown much faster than image display
Perry> memory. With a full screen image of 1024x1280 pixels, we
Perry> are only talking about 5MB or so for a 32-bit deep
Perry> display. Converting rgba all to floats means 20MB, while
Perry> large is not overwhelming these days, and that is the worst
Perry> case for interactive cases. I suppose it would be a bigger
Perry> concern for non-interactive situations (e.g. PDF). But it
Perry> would seem that in doing this simpler approach, we would
Perry> have something that works sooner, and then we could think
Perry> about how to handle cases where someone wants to generate a
Perry> 4Kx4K PDF image (which is going to be one big PDF
Perry> file!). I'd let's not let extreme cases like this drive the
Perry> first implementation.
Agreed. If noone has any objections I think I'll start with rgba32 as
the common rendering format for the image module and we can special
case the smaller (grayscale UInt8 or UInt16) and larger (rgba floats)
cases after a prototype implementation.
I'm imagining an interface like
Frontend:
im = image.fromarray(A) # NxM
im = image.fromarray(A, colormap) # NxM colormapped images
im = image.fromarray(A) # NxMx3, no format needed
im = image.fromarray(A) # NxMx4, no format needed
im = image.fromfile('somefile.png')
im.set_interpolate(image.BILINEAR)
im.set_aspect_ratio(image.CONSTRAINED)
Backend:
def draw_image(im):
# Ascaled is width x height x 4 resampled using interpolation
# and aspect constraints from above
Ascaled = im.resize(viewport.width, viewport.height)
renderer.draw_from_rgba(Ascaled, etc1, etc2)
Perry> Well, I was just referring to the image file support that
Perry> PIL supplies; the rest of PIL seems mostly redundant with
Perry> matplotlib and array capabilities (if I remember right, I
Perry> haven't really used PIL much). How much image file format
Perry> support is built into agg?
Almost none, except for the raw (or almost raw) image types (ppm,
bmp). PNG, I have more or less figured out; borrowing the read/write
capabilities for other image format from PIL is a good idea.
JDH
|