great news with regards to OpenCV support...

Chris Colbert sccolbert at gmail.com
Thu Oct 8 19:03:58 EDT 2009


On Fri, Oct 9, 2009 at 12:45 AM, Ralf Gommers
<ralf.gommers at googlemail.com> wrote:
>
>
> On Thu, Oct 8, 2009 at 11:42 PM, Chris Colbert <sccolbert at gmail.com> wrote:
>>
>> On Thu, Oct 8, 2009 at 11:38 PM, Damian Eads <eads at soe.ucsc.edu> wrote:
>> >
>> > On Thu, Oct 8, 2009 at 2:18 PM, Chris Colbert <sccolbert at gmail.com>
>> > wrote:
>> >>
>> >> So my next question is: how much hand holding should I do on my end
>> >> for the user?
>> >>
>> >> There are several things I would like to address here:
>> >>
>> >> - opencv makes extensive use of *out arguments, should we require the
>> >> user to
>> >>  preallocate their out array or should we make it for them and return
>> >> it.
>> >>  The latter option is more pythonic, but comes with a small overhead
>> >> for
>> >>  determining a proper return dtype
>> >
>> > I think having out be None by default is best.
>> >
>>
>> That's how i've been going about it so far, but that obviously incurs
>> an overhead of determining, exactly if and what to return.
>
> Doing it the same as for ufuncs would make sense I think. Is that what you
> mean by "having out None"? The overhead should be small compared to most
> operations on images.
>
> Ufuncs return a view on `out` if given by the user. scipy.ndimage returns
> None in that case. I think returning a view is more convenient.
>
> Cheers,
> Ralf
>
>


So far, I've been doing it like this:

If the user passes an 'out' array, I verify that its compatible for
the operation.
If the user does not pass an out array, I create an appropriate one for them.


The final case is operations that can performed in place by opencv. In
these cases, the function takes an extra boolean kwarg 'in_place'. If
true, the operation is performed in place. This is done by assiging
'src' to 'out' and passing both to opencv.

In all these cases, I return the 'out' array. So if the user supplied
it or requested inplace, they can just ignore the return value.

Cheers!

Chris



More information about the scikit-image mailing list