Feature Request: RectangleSelector BlockingInput

The new ginput function is great.

Would it be possible to have a version that looks to the user like a
RectangleSelector widget but works for the programmer like ginput? That is,
it returns the coordinates of the rectangle.

This would be really useful for implementing a user image crop function,
similar to matlab's imcrop for example.

One can functionally do this with:

import os.path, sys
import pylab
import Image

img = Image.open('test_image.png')
fig = pylab.imshow(img, origin='lower')
print "Please click on top left, bottom right of crop area"
x = pylab.ginput(2)
#PIL and matplotlib have different origin
roi = img.crop([int(x[0][0]),int(img.size[1]-x[0][1]),
int(x[1][0]),int(img.size[1]-x[1][1])])
filenm = os.path.join(sys.path[0], 'crop_image.png')
roi.save(filenm)
show()

But users expect a rectangle for cropping.

I've had a look a the BlockingMouseInput class but its all a bit beyond me
at the moment.

Eleanor

···

--
View this message in context: http://www.nabble.com/Feature-Request%3A-RectangleSelector-BlockingInput-tp18841798p18841798.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

David, since you are a recent matlab user and are deeply versed in the
blocking code: how hard would it be to simply provide a (mostly)
matlab compatible imcrop function, and is this something you are
interested in doing?

JDH

···

On Tue, Aug 5, 2008 at 6:26 PM, Elfnor <elfnor@...287...> wrote:

This would be really useful for implementing a user image crop function,
similar to matlab's imcrop for example.

Hi,

Sorry for the long delay - I have been on vacation. I don't use the
imcrop function, but it looks fairly easy to implement using ginput. I
am heading off for vacation again for another two weeks and I want to
get in some of the changes I proposed a long while ago before working on
this, so it might be a while, but if no one can take it on first, I can
give a look next month.

Cheers,
David

···

On Tue, 2008-08-05 at 19:51 -0500, John Hunter wrote:

On Tue, Aug 5, 2008 at 6:26 PM, Elfnor <elfnor@...287...> wrote:

> This would be really useful for implementing a user image crop function,
> similar to matlab's imcrop for example.

David, since you are a recent matlab user and are deeply versed in the
blocking code: how hard would it be to simply provide a (mostly)
matlab compatible imcrop function, and is this something you are
interested in doing?

JDH

--
**********************************
David M. Kaplan
Charge de Recherche 1
Institut de Recherche pour le Developpement
Centre de Recherche Halieutique Mediterraneenne et Tropicale
av. Jean Monnet
B.P. 171
34203 Sete cedex
France

Phone: +33 (0)4 99 57 32 27
Fax: +33 (0)4 99 57 32 95
http://www.ur097.ird.fr/team/dkaplan/index.html
**********************************