On 13-aug-2006, at 16:44, Jaret Hargreaves wrote:
> I am performing an image filtering algorithm developed in objc and
> calling it from python. Currently, the relevant python code looks as
> # Create the raw string from the current slice (data[i])
> rawstr = data[i].tostring()
is data[i] a numeric/numpy/numarray object? If those support the
buffer protocol you should be able to avoid a copy here: PyObjC
automaticly proxies anything that supports the buffer protocol as an
> # Perform filtering using anisoTools framework
> newMRC.dictionary['dimensions'], 2, self.kCI, self.iterCI)
> # Convert string result from filtering back to float and reshape to
> original slice dimensions
> data[i] = reshape(fromstring(rawstr,Float32),(256,256))
> The objC method uses a memcpy command to create a local copy and then
> generates a CIImage ("inputImage"). This CIImage is filtered and
> available as "outputImage". The relevant code is below:
> How do I copy the results from the resulting CIImage ("outputImage")
> back into inputData for the final memcpy out?
I haven't played with CoreImage yet (shame on me), so can't help you
there. My guess is that you should render the CIImage into an
NSBitmapImage and fetch the bytes that way.
Adding utility functions/classes to do translations like this and add
support for PIL<->NSImage conversion to PyObjCTools would be a nice
feature to have ;-).