Turns image into binary (ie black and white) image and determines the largest rectangle encompassing a (white) object in the middle to crop to.
When looking for a black object, check the 'invert' option.
Simple cropping algorithm that assumes a good contrast between background and foreground.
- create histogram of grayscale image
- remove counts from histogram that fall below noise-level
- determine left-most (L) and right-most (R) non-zero count
- divide region between L and R into two and determine highest peak in each (LP and RP)
- 8-bit threshold is halfway between LP and RP
- determine first pixel that is above threshold from top, bottom, left and right, which is used for the crop