Hello,
We are intested in automatically cropping black space from around scanned images. All of the images are in jpg and vary in sizes. Is this possible? I tried the automatic crop feature, but could not get it to crop any of the images.
I've just started using XnView and wanted to evaluate it to see if it can automatically crop these images.
Thank you for any help!
Albert
Automatically Crop Black Space Around JPGS
Moderators: XnTriq, helmut, xnview
Re: Automatically Crop Black Space Around JPGS
Thank you for your help. I have attached one (compressed).
We scan a number of new items everyweek and are interested in a way to eliminate the black area around the book. Unfortunately, books come in a wide variety of sizes, so trying to crop by dimensions is a bit of a problem.
Albert
We scan a number of new items everyweek and are interested in a way to eliminate the black area around the book. Unfortunately, books come in a wide variety of sizes, so trying to crop by dimensions is a bit of a problem.
Albert
- Attachments
-
- SKMBT_C36013062409140.jpg (64.2 KiB) Viewed 2813 times
Re: Automatically Crop Black Space Around JPGS
I think the immediate problem is that the area to be auto-cropped consists of a thin near-white border, a narrow gray band and then the main near-black area: at best the scan could only be successfully auto-cropped with a series of auto-crops using different background colour selections. High tolerance settings can be entered and might be helpful -- the maximum value that can be entered is 128 from memory!
But the usual way to scan a multi-page document like a book is to place each page in the same position -- for example the top left corner -- on the scanner glass and then use the scanner software to make a selection around the page to be scanned, so that only the wanted area is scanned. That is a basic scanner function that should be available in almost any scanner.
If for some reason it isn't possible to scan just the wanted area, it would probably be more practical to position each page in the same location, as above, and then batch-crop the resulting scans to remove the unwanted part, rather than use auto-crop.
Edit:
Given reasonable quality page scans -- which would typically have a nominally-white colour -- the auto-crop function can be useful to enhance the images by, for example, removing any stray dark marks in the margins. That operation can then be followed by a 'Canvas resize' to set a constant page size and whatever margins are desired. Both enhancement operations can be done using batch operations. Useful for the perfectionist!
But the usual way to scan a multi-page document like a book is to place each page in the same position -- for example the top left corner -- on the scanner glass and then use the scanner software to make a selection around the page to be scanned, so that only the wanted area is scanned. That is a basic scanner function that should be available in almost any scanner.
If for some reason it isn't possible to scan just the wanted area, it would probably be more practical to position each page in the same location, as above, and then batch-crop the resulting scans to remove the unwanted part, rather than use auto-crop.
Edit:
Given reasonable quality page scans -- which would typically have a nominally-white colour -- the auto-crop function can be useful to enhance the images by, for example, removing any stray dark marks in the margins. That operation can then be followed by a 'Canvas resize' to set a constant page size and whatever margins are desired. Both enhancement operations can be done using batch operations. Useful for the perfectionist!
Re: Automatically Crop Black Space Around JPGS
Thank you for the resonse!
Yes, I can see that there are some areas of grey & white that might be preventing the auto crop from working. I will experiment with the settings. Sorry I didn't make myself clear, but we only scan the covers to use on our website. So the quality is not as important as the quantity.
Take care!
Albert
Yes, I can see that there are some areas of grey & white that might be preventing the auto crop from working. I will experiment with the settings. Sorry I didn't make myself clear, but we only scan the covers to use on our website. So the quality is not as important as the quantity.
Take care!
Albert
Re: Automatically Crop Black Space Around JPGS
I suspect that you will find that even scanning just the covers it will be quicker in the end to use the scanner software to make a selection around just the area that you want scanned, so that no further processing is required!
With practice setting the scan area to just the book cover should be very quick, possibly only a few seconds. Insetting the scan very slightly from the edges of the cover may give a cleaner image.
If you need to regularly scan a large number of book covers, it might be possible to develop an auto-crop procedure using multiple auto-crops, if required, run as a batch process on a folder of images, and possibly save some time. But the fact that book covers come in all colours might prove a practical limitation.
If you want to test that route, it might be worth trying insetting the crop area very slightly to see if the thin white lines on some edges can be eliminated. It might also be worth placing matte black art paper over the white inside cover of the scanner lid, to see if that reduces reflections that may be the source of the narrow gray band on the left of the above scan.
With practice setting the scan area to just the book cover should be very quick, possibly only a few seconds. Insetting the scan very slightly from the edges of the cover may give a cleaner image.
If you need to regularly scan a large number of book covers, it might be possible to develop an auto-crop procedure using multiple auto-crops, if required, run as a batch process on a folder of images, and possibly save some time. But the fact that book covers come in all colours might prove a practical limitation.
If you want to test that route, it might be worth trying insetting the crop area very slightly to see if the thin white lines on some edges can be eliminated. It might also be worth placing matte black art paper over the white inside cover of the scanner lid, to see if that reduces reflections that may be the source of the narrow gray band on the left of the above scan.
Re: Automatically Crop Black Space Around JPGS
I would try increasing contrast first and then doing the autocrop.
Or maybe SCAN TAILOR is your friend.
Or maybe SCAN TAILOR is your friend.
Intel i7 5960X
Gigabye GA-X99-Gaming 5
8 GB DDR4 (2100)
GeForce GTX 970 (Gigabyte)
Gigabye GA-X99-Gaming 5
8 GB DDR4 (2100)
GeForce GTX 970 (Gigabyte)
Re: Automatically Crop Black Space Around JPGS
Increasing contrast might be helpful but the object as I understand it is to produce simple images of book covers quickly, so I'm not sure whether the widely-regarded ScanTailor would be useful. What would be useful is scanner software that automatically detects the area to be scanned, does that exist?
Correction: The maximum tolerance that can be set in XnView is 255, rather than the 128 stated from memory in my first post. XnViewMP and XnConvert are still limited to 99, I think, despite an earlier request for a higher value; 255 is very high but does no harm, and given the likely limited understanding of how to use Auto-crop, quite high values can certainly be useful sometimes (see below).
I have found a two-step process that seems to produce the desired result on the test image above:
1. Crop slightly inside the left, top and bottom edges (say at 90 or 95% of the width and height);
2. Auto-crop using R = G = B = 64 and Tolerance = 150
That two-step process could be implemented on a folder of images using a single XnView batch operation (or possibly better using a batch file calling NConvert).
Those values seem to work but haven't been optimised at all, and the wide range of book cover colours still seems likely to present a problem.
Correction: The maximum tolerance that can be set in XnView is 255, rather than the 128 stated from memory in my first post. XnViewMP and XnConvert are still limited to 99, I think, despite an earlier request for a higher value; 255 is very high but does no harm, and given the likely limited understanding of how to use Auto-crop, quite high values can certainly be useful sometimes (see below).
I have found a two-step process that seems to produce the desired result on the test image above:
1. Crop slightly inside the left, top and bottom edges (say at 90 or 95% of the width and height);
2. Auto-crop using R = G = B = 64 and Tolerance = 150
That two-step process could be implemented on a folder of images using a single XnView batch operation (or possibly better using a batch file calling NConvert).
Those values seem to work but haven't been optimised at all, and the wide range of book cover colours still seems likely to present a problem.
Re: Automatically Crop Black Space Around JPGS
Most scanner drivers have an option to do a Preview first, where you can set a scanning area. Canon even has got an "detect area" feature. You are scanning a too wide area. And unless your scanner controls allow you to adjust contrast/gamma/area you are out of luck for properly doing an "auto-crop".
PS - I also strongly advise against using lossy JPEG compression when scanning. It kills text quality and tend to make things bigger and blurrier than they are really are.
BTW: This is what the original image should look like. The 8bpp PNG is also smaller than its original JPEG counterpart.
PS - I also strongly advise against using lossy JPEG compression when scanning. It kills text quality and tend to make things bigger and blurrier than they are really are.
BTW: This is what the original image should look like. The 8bpp PNG is also smaller than its original JPEG counterpart.
Intel i7 5960X
Gigabye GA-X99-Gaming 5
8 GB DDR4 (2100)
GeForce GTX 970 (Gigabyte)
Gigabye GA-X99-Gaming 5
8 GB DDR4 (2100)
GeForce GTX 970 (Gigabyte)