Auto Trim white objects

Ask for help and post your question on how to use XnView Classic.

Moderators: XnTriq, xnview

Post Reply
mrbombay
Posts: 3
Joined: Thu Feb 07, 2013 6:25 am

Auto Trim white objects

Post by mrbombay » Thu Feb 07, 2013 6:46 am

Hello,

We have like more then 5000 pictures to trim around picture.

Does anybody have the right settings for this?

Here you have a difficult example from one picture...
Attachments
351044_08.jpg
351044_08.jpg (133.07 KiB) Viewed 1484 times

eL_PuSHeR
Posts: 267
Joined: Sat Apr 25, 2009 9:23 am

Re: Trim white objects

Post by eL_PuSHeR » Thu Feb 07, 2013 8:18 am

Do you mean autocrop? ALT-Y
Intel i7 5960X
Gigabye GA-X99-Gaming 5
8 GB DDR4 (2100)
GeForce GTX 970 (Gigabyte)

User avatar
DOS386
Posts: 291
Joined: Sun Jun 11, 2006 2:43 pm

Re: Trim white objects

Post by DOS386 » Thu Feb 07, 2013 9:01 am

> We have like more then 5000 pictures to trim around picture.

COOL :-)

> Here you have a difficult example from one picture...

I'm getting best results with Tolerance 21 ... but AutoCrop is not smart ... you have to find out the background color (here white, no problem) and the tolerance (big problem: here 27 is too much already) yourself.
Attachments
crop128.jpg
crop128.jpg (27.95 KiB) Viewed 1476 times
There is indeed no WinZIP under my rock.

User avatar
helmut
Posts: 8195
Joined: Sun Oct 12, 2003 6:47 pm
Location: Frankfurt, Germany

Re: Trim white objects

Post by helmut » Mon Feb 11, 2013 11:02 pm

Hmm, I wonder whether the background colour could be determined automatically by XnView.

Auto-colour and Auto-tolerance
If a user applies automatic crop, he/she indicates/knows that there is a surrounding background and an object in the image. Otherwise, triggering auto-crop would not make sense.

Given the above assumption, both colour and tolerance could be determined automatically by XnView inspecting all border points of the image. The auto-colour would be the average out of all colours. And the auto-tolerance would be the tolerance found in the colour values of all border pixels.

Applying auto-crop to an image multiple times with auto-colour and auto-tolerance would end up in a mess. To avoid this, reasonable maximum values might help.

Currently, auto-colour and auto-tolerance in auto-crop are not supported. These are just some first thoughts how this might work. Probably much more thinking and even trial-and-error would be needed to make this really fly.

User avatar
DOS386
Posts: 291
Joined: Sun Jun 11, 2006 2:43 pm

Re: Trim white objects

Post by DOS386 » Tue Feb 12, 2013 8:04 am

> both colour and tolerance could be determined automatically by XnView

not really

> inspecting all border points of the image. The auto-colour would be the average out of all colours

no problem

> And the auto-tolerance would be the tolerance found in the colour values of all border pixels

This won't work. A few almost invisible dark noise pixels at the border will enforce a high tolerance eating up parts of the valuable image (see above).

> Applying auto-crop to an image multiple times with auto-colour and auto-tolerance
> would end up in a mess. To avoid this, reasonable maximum values might help.

Can't reproduce this.
There is indeed no WinZIP under my rock.

User avatar
XnTriq
Moderator & Librarian
Posts: 5543
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: Trim white objects

Post by XnTriq » Tue Feb 12, 2013 8:45 pm

Suggestions: visual batch crop

Content-aware cropping:
Peter Sobot ([url=http://www.petersobot.com/blog/a-use-for-smartphone-photos/]A Use for Smartphone Photos[/url]) wrote:Michael Macias, in a submission to a Codebrawl last November, came up with a brilliantly simple method of content-aware image cropping. By measuring the greyscale entropy of a window as it slides over an image, the highest-interest thumbnail can be determined automatically.

User avatar
helmut
Posts: 8195
Joined: Sun Oct 12, 2003 6:47 pm
Location: Frankfurt, Germany

Re: Trim white objects

Post by helmut » Tue Feb 19, 2013 10:40 pm

DOS386 wrote:>> And the auto-tolerance would be the tolerance found in the colour values of all border pixels

>This won't work. A few almost invisible dark noise pixels at the border will enforce a high tolerance eating up parts of the valuable image (see above).
Hmm, I can't see why this shouldn't work. If you have dark noise pixels at the border, then auto-crop the way it works now is at a loss anyway, even when setting both colour and tolerance values manually, isn' it?

I'm pretty sure that there is a way to automate this and to achieve a good result for images with a background like the ones shown above.

@XnTriq: Thanks for the links. I had a look at the sample pictures of Michael Macias and found the sample results not overwhelming. Yet, I guess the sample pictures were very difficult for automatic cropping. I assume with above sample image (sport shoe) and similar images the results would be reasonable.

User avatar
XnTriq
Moderator & Librarian
Posts: 5543
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: Trim white objects

Post by XnTriq » Wed Feb 20, 2013 9:30 pm

helmut wrote:@XnTriq: Thanks for the links. I had a look at the sample pictures of Michael Macias and found the sample results not overwhelming.
Croppola's output of 351044_08.jpg is also disappointing :-|
I'm confident, though, that algorithms for content-aware cropping will eventually be improved.

If the Gamma (Image » Adjust » Brightness/Contrast/Gamma/Balance...) of 351044_08.jpg is decreased, it becomes apparent that the shoe was placed on a turntable. This leads me to the conclusion that all/many of mrbombay's 5K product photos may well have been shot under the same or similar conditions.
Batch-cropping seems to be a viable option in this case.
  • Tools » Batch Processing... » Transformations » Image » Crop
    • X [ 250 ]
      Y [ 150 ]
      Width [ 720 ]
      Height [ 540 ]

Post Reply