From: Nils W. <nw...@ia...> - 2009-06-09 17:41:01
|
Hi all, I am looking for an autocrop function. It should remove borders from an image. Is it available in matplotlib ? Any pointer would be appreciated. Thanks in advance Nils |
From: Anton V. <vas...@ya...> - 2009-06-09 18:31:26
|
I wasn't able to find one in Matplotlib but you can use PIL library for all the imaging work. Really easy to use. Here is the webpage for it: http://www.pythonware.com/products/pil/index.htm Anton ________________________________ From: Nils Wagner <nw...@ia...> To: mat...@li... Sent: Tuesday, June 9, 2009 10:22:05 AM Subject: [Matplotlib-users] autocrop function Hi all, I am looking for an autocrop function. It should remove borders from an image. Is it available in matplotlib ? Any pointer would be appreciated. Thanks in advance Nils ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Matplotlib-users mailing list Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
From: Nils W. <nw...@ia...> - 2009-06-09 19:10:57
|
On Tue, 9 Jun 2009 11:31:19 -0700 (PDT) Anton Vasilescu <vas...@ya...> wrote: > I wasn't able to find one in Matplotlib but you can use >PIL library for all the imaging work. Really easy to use. > Here is the webpage for it: >http://www.pythonware.com/products/pil/index.htm > > Anton > > Hi Anton, Thank you for your prompt reply. I am aware of PIL. However I didn't find an autocrop function within PIL. Cheers, Nils from PIL import Image im = Image.open('test.png') # # Calculates the bounding box of the non-zero regions in the image. # The bounding box is returned as a 4-tuple defining # the left, upper, right, and lower pixel coordinate. # If the image is completely empty, this method returns None. # print im.getbbox() print im.size # # Returns a rectangular region from the current image. # The box is a 4-tuple defining the left, upper, right, and lower # box = (100, 100, 800, 800) region = im.crop(box) region.show() It would be nice to compute the box automatically. Any idea ? |
From: Jae-Joon L. <lee...@gm...> - 2009-06-10 06:28:42
|
If you're using very recent version of mpl, you may try savefig with "bbox_inches" option. savefig("a.png", bbox_inches="tight") The algorithm is not perfect, but will work for most of simple plots. Regards, -JJ On Tue, Jun 9, 2009 at 1:22 PM, Nils Wagner<nw...@ia...> wrote: > Hi all, > > I am looking for an autocrop function. > > It should remove borders from an image. > Is it available in matplotlib ? > > Any pointer would be appreciated. > > Thanks in advance > > Nils > > > > > ------------------------------------------------------------------------------ > Crystal Reports - New Free Runtime and 30 Day Trial > Check out the new simplified licensing option that enables unlimited > royalty-free distribution of the report engine for externally facing > server and web deployment. > http://p.sf.net/sfu/businessobjects > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
From: Nils W. <nw...@ia...> - 2009-06-10 16:25:56
Attachments:
example.tar.bz2
|
On Wed, 10 Jun 2009 02:26:54 -0400 Jae-Joon Lee <lee...@gm...> wrote: > If you're using very recent version of mpl, you may try >savefig with > "bbox_inches" option. > > savefig("a.png", bbox_inches="tight") > > The algorithm is not perfect, but will work for most of >simple plots. > > Regards, > > -JJ > Hm, it doesn't work as expected. Am I missing something ? The example is attached. Cheers, Nils |
From: Jae-Joon L. <lee...@gm...> - 2009-06-10 20:32:13
|
I guess I misunderstood your intention. As you posted the message in the mpl list, I assumed that you want to crop out the boundary of the mpl figure, which seems to be not the case. Sorry for the noise. -JJ On Wed, Jun 10, 2009 at 12:09 PM, Nils Wagner<nw...@ia...> wrote: > On Wed, 10 Jun 2009 02:26:54 -0400 > Jae-Joon Lee <lee...@gm...> wrote: >> >> If you're using very recent version of mpl, you may try savefig with >> "bbox_inches" option. >> >> savefig("a.png", bbox_inches="tight") >> >> The algorithm is not perfect, but will work for most of simple plots. >> >> Regards, >> >> -JJ >> > Hm, it doesn't work as expected. Am I missing something ? > The example is attached. > > Cheers, > Nils > |
From: Nils W. <nw...@ia...> - 2009-06-11 06:52:51
Attachments:
autocrop.png
|
On Wed, 10 Jun 2009 16:32:08 -0400 Jae-Joon Lee <lee...@gm...> wrote: > I guess I misunderstood your intention. > As you posted the message in the mpl list, I assumed >that you want to > crop out the boundary of the mpl figure, which seems to >be not the > case. > Sorry for the noise. > > -JJ Please find attached the result of gimp's autocrop function. That is the target. Cheers, Nils |
From: Nils W. <nw...@ia...> - 2009-06-23 15:30:02
Attachments:
script-autocrop.scm
|
On Wed, 10 Jun 2009 16:32:08 -0400 Jae-Joon Lee <lee...@gm...> wrote: > I guess I misunderstood your intention. > As you posted the message in the mpl list, I assumed >that you want to > crop out the boundary of the mpl figure, which seems to >be not the > case. > Sorry for the noise. > > -JJ > Hi, I found a way to run gimp (gimp2.2) in batch mode. gimp --batch-interpreter plug_in_script_fu_eval -i -d -b '(script-autocrop "/home/nwagner/test.png")' '(gimp-quit 0)' Now I would like to run gimp from python using subprocess, popen2 or os.system. How do I call gimp with the arguments from python ? Nils |