Hello colleague,

On Thursday, May 14, 2015 at 11:24:49 AM UTC+2, Andrew Gibb wrote:
>
> I'd like to create an interactive tool which draws a circle over an image. 
> Sliders will enable the radius and centre position of the circle to be set. 
> The following code works, but is very slow:
>
> using PyPlot, Interact, PyCall, Images, TestImages
> @pyimport matplotlib.patches as patch
>
> myim = testimage("mandrill")
> f = figure()
> @manipulate for r in 0:100
>     withfig(f) do 
>         ax = f[:add_subplot](1,1,1)
>         ax[:imshow](separate(myim))
>         c = patch.Circle((200.0, 200.0), alpha=0.2)
>         c[:radius] = r
>         ax[:add_artist](c)
>     end
> end
>
> Obviously I've omitted the centre location interaction. Running in IJulia, 
> the delay between moving the slider and circle changing its shape is 3-15 
> seconds. 
>
> Can anyone suggest ways to speed this up? 
>
> Well, not directly. If you need interaction that works at a reasonable 
speed,  you need to reduce a little bit the numbers of layers between you 
input and output. Using iJulia together with matplotlib in python and some 
julia interfacing inbetween is for sure build an impressive stack of 
layers. As said before, there is no easy way out, but i'd recommend to look 
a little bit a Gtk.jl if you can use native, local windows. If you are 
bound to iJulia (so routing all input/output through a browser/server 
connection) my first guess would be to replace matplotlib with something 
'lighter'.

 

Reply via email to