Crop image based on pixel color

Roger.E.Eller at sealedair.com Roger.E.Eller at sealedair.com
Sat Oct 29 17:02:21 EDT 2005


A few moments ago, Scott Rossi <scott at tactilemedia.com> wrote:
> Recently, Roger.E.Eller at sealedair.com  wrote:
> 
>> Imagine a jpg or png image (any format really) that has white space all
>> around the image. What would be the most efficient way to sample the
>> colors (quickly) and determine a rect that can be used to crop the 
image?
>> Has this been done before? Got scripts?
> 
> If you could guarantee that that the space around the image was *truly*
> white (or some other solid color) and the images were not huge then this
> *might* be possible to some extent.  However, many images, most notably
> JPEGs, can have color variations in the white space due to compression,
> which makes this a tough thing for Rev to do natively if you want it 
done fast.

Determining if a pixel is 'lighter than' some value would be ok. It 
doesn't have to be absolute white. The goal is to present the user with an 
adjustable crop box that has already positioned itself 'close' to the 
desired crop rect.

> The other issue is, if the white space is irregular, then you
> basically need to sample virtually every point around image, looking for
> non-white-space color changes.  Again, I might be wrong but I think this
> would be hard to do natively if it needs to be fast.

These images are huge. What I envision is a method that would 'look at' 
every 10th or 20th pixel as it loops through the image (for improved 
speed). In most cases, it would still achieve a rect that represents the 
boundaries of the image. The user would then make slight manual 
adjustments to the crop box.

> I know Chipp Walters of Altuit was working with some kind of 
Photoshop-like
> algorithms or libraries -- maybe he has some insight.

I hope he releases altCropMagic (in the style of his other wonderful 
stacks)!  ;-)   Come on Chipp!!!

> Regards,
> 
> Scott Rossi
> Creative Director
> Tactile Media, Multimedia & Design

Kind regards,
Roger Eller <roger.e.eller at sealedair.com>




More information about the use-livecode mailing list