Cython help: Time taken to execute a function (profiling) changes drastically depending on image size

Tony Yu tsyu80 at gmail.com
Sun Jul 21 12:47:11 EDT 2013


On Sun, Jul 21, 2013 at 4:45 AM, Chintak Sheth <chintaksheth at gmail.com>wrote:

> Hi,
>
> I am writing the code for Image inpainting using Fast Marching Method.
> After writing the initial implementation in Python, I am now cythonising
> parts of the code [1]. After profiling, the majority of the time is taken
> by the 3 function in [2]. In particular, even after cythonizing,
> `inpaint_point` takes the majority of the time.
>
> The results of profiling for 2 different image sizes are here
> http://pastebin.com/aTY1bbn6. The first result is for image size of
> 100X100 and the second one for 512X512. The mask size which I use is
> constant for both cases. So, the number of function calls to
> `inpaint_point` for both are the same as can be seem in the profiling
> result.
>
> Still why do I get such a drastic time difference in the 2 cases ? Any
> ideas, what I am missing here or doing inefficiently ?
>


Having different Cython functions using different copies of your data (i.e.
one version as uint8, one as float) seems like a bad idea. And making that
copy inside of a loop is probably killing performance:
https://github.com/chintak/scikit-image/blob/inpaint/skimage/inpaint/_inpaint.pyx#L179


> Chintak
>
> [1] https://github.com/chintak/scikit-image/tree/inpaint/skimage/inpaint
>
> [2]
> https://github.com/chintak/scikit-image/blob/inpaint/skimage/inpaint/_inpaint.pyx
>
>   --
> You received this message because you are subscribed to the Google Groups
> "scikit-image" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to scikit-image+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20130721/fa617fca/attachment.html>


More information about the scikit-image mailing list