Page 4 of 4
Re: Smart crop function in IM?
Posted: 2017-07-06T16:43:40-07:00
by snibgo
Fred: Corner detectors look interesting. Another topic to add to my reading list. Thanks.
It's too late tonight to look closely at your code, but it seems okay.
fmw42 wrote:Comet blur 1 and blur=20:
Those results are almost the same as my ones that trim to all components. An obvious difference in the first image is: I have both cat's eyes, you have one and a half eyes. My code goes around the houses, calling other scripts to do the comet work, so I suspect your result is more accurate than mine.
Re: Smart crop function in IM?
Posted: 2017-07-06T16:59:36-07:00
by fmw42
You have to sets of results for the sofa cat. What were the comet blur amounts for the top and bottom. Where both sets with CCL filtering or was one with and one without? Perhaps I misunderstood what you showed.
No problem about being late. Answer tomorrow is perfectly fine.
Check out my corner script for links to the harris and shi-tomasi corner methods.
Re: Smart crop function in IM?
Posted: 2017-07-07T11:31:45-07:00
by snibgo
My two results above for sofa_cat_small.jpg use sigma=1 for the comet, and sigma=20 for the main blur. The thresholds are 99,97,95,90,85,80. The first set of six images trim to all the components. The second set trim to just the largest component.
There is another difference between my script and Fred's. Trimming to one or all components gives crop parameters WxH+X+Y. We can either use these parameters directly to crop the input image, or we can ignore +X+Y and then use the "white rectangle" method to find the best offsets for WxH (which I implement as a recursive call to the script).
The recursive method gives a different result (and is slower). It is currently my default, because it always seems better.
After another day of hacking, I've got a scheme that gives good results on all these input images, whether the user supplies both dimensions, only one, or none. Moreover, we get good results for a wide range of thresholds. More work is required, including testing with large images.
The details are too complex for this post. See
Crop to detail.
Re: Smart crop function in IM?
Posted: 2017-07-07T12:03:58-07:00
by fmw42
Thanks for the answers and the detailed explanation in your linked code. Very nice.
Re: Smart crop function in IM?
Posted: 2017-07-12T05:34:17-07:00
by snibgo
I've uploaded a new version of the
Crop to detail page, with new sections for references and large images, and improvements to "How does it work?".
The main script is now called cropToDetailSml.bat, and copes well with small images. For large images, use cropToDetailLge.bat. The page has many examples.
Re: Smart crop function in IM?
Posted: 2017-07-12T09:22:20-07:00
by fmw42
Your Auto croppng for digital photographs, Zhang et al, 2005 returns access denied.
Re: Smart crop function in IM?
Posted: 2017-07-12T09:44:06-07:00
by snibgo
Thanks. A good address for that paper is:
https://pdfs.semanticscholar.org/2d2a/e ... dc8e13.pdf
(And I will learn how to spell "cropping".)
Re: Smart crop function in IM?
Posted: 2017-07-14T15:49:10-07:00
by fmw42
I have implemented a new script, smarttrim, that automatically trims an image around the region of highest detail in the image. This is similar to snibgo's work and does borrow many of his concepts (thanks snibgo). My script allows a choice of metrics for detecting the detail in the image, including: sobel edges, canny edges, local standard-deviation processing and corner detection.
Re: Smart crop function in IM?
Posted: 2017-07-15T12:20:07-07:00
by fmw42
An interesting observation -- I found that these smart trim scripts seem to be able to process scanned text image with moderately smooth but complex background colors. The corner metric for detail processing seems to do best in the few cases I tested. See my script, smartrim, for examples. Unfortunately, results are dependent upon the threshold/fuzz value.
Re: Smart crop function in IM?
Posted: 2017-10-11T13:06:59-07:00
by lloyd_lloyd
Hi snibgo,
I've tried using your smart cropping batch files; I downloaded the zip file from
http://im.snibgo.com/zipbats.htm and ran cropToDetailSml.bat, but it would seem that there is a file missing: the scripts call gaussSlpMag, but there is no such batch file. Is this an oversight or do I need to compile or obtain some sort of further dependency?
All the best,
Lloyd
Re: Smart crop function in IM?
Posted: 2017-10-11T13:24:19-07:00
by snibgo
Oops, sorry about that. I've uploaded it to
http://snibgo.com/imforums/gaussSlpMag.bat , and it will eventually be included in the usual zip file.
EDIT: Ah, sorry, gaussSlpMag.bat uses a utility program chStrs.exe, and I don't provide the source or binary of that. Those four lines change the contents of four files, named %KNL_L% etc. In each, the first colon ":" on every line is changed to "+%OFFS%+%OFFS%:" (without the quotes).
Re: Smart crop function in IM?
Posted: 2017-10-12T13:21:03-07:00
by lloyd_lloyd
Thanks, I'll be giving it a shot later!
Re: Smart crop function in IM?
Posted: 2017-10-14T07:53:38-07:00
by lloyd_lloyd
Hi again,
I've successfully compiled IM7 along with your img2knl process module; however, it looks like gaussSlpMag.bat depends on another missing script, mSliceGauss.bat, so I haven't had much luck getting a final result so far.
Also, a small note to help you out: in img2knl.c, on line 70, you use "image->matte"; this does not seem to exist in IM7, which you anticipated in vsn_defines.h, but apparently forgot to use. Replacing it with "IS_ALPHA_CH(image)" at least gets the module to compile without error.
Thanks for your effort so far!
Re: Smart crop function in IM?
Posted: 2017-10-14T08:17:28-07:00
by snibgo
Thanks. I've uploaded
http://snibgo.com/imforums/mSliceGauss.bat for you, and the modules you mention will be in the next edition of the zip file, whenever that is.
I don't normally use v7, but I recently recompiled all my modules under v7, and caught the error you pointed out. As you say, it needed "IS_ALPHA_CH(image)".
Re: Smart crop function in IM?
Posted: 2017-10-14T10:08:33-07:00
by lloyd_lloyd
Thanks, it's working now! I'll need to experiment with different settings to see what works best for my particular case (dealing mostly with illustrations rather than photos), but I'm glad you shared your work.