Merge pull request #1103 from jcupitt/add-smartcrop-low-high

add low/high to smartcrop
This commit is contained in:
John Cupitt 2018-09-24 10:56:49 +01:00 committed by GitHub
commit 7da31386c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 3 deletions

View File

@ -1,4 +1,6 @@
21/9/18 started 8.8.0
- much faster smartcrop [lovell]
- add low/high to smartcrop [jcupitt]
23/9/18 started 8.7.1
- update function list in docs [janko-m]

View File

@ -212,11 +212,17 @@
* @VIPS_INTERESTING_CENTRE: just take the centre
* @VIPS_INTERESTING_ENTROPY: use an entropy measure
* @VIPS_INTERESTING_ATTENTION: look for features likely to draw human attention
* @VIPS_INTERESTING_LOW: position the crop towards the low coordinate
* @VIPS_INTERESTING_HIGH: position the crop towards the high coordinate
*
* Pick the algorithm vips uses to decide image "interestingness". This is used
* by vips_smartcrop(), for example, to decide what parts of the image to
* keep.
*
* #VIPS_INTERESTING_NONE and #VIPS_INTERESTING_LOW mean the same -- the
* crop is positioned at the top or left. #VIPS_INTERESTING_HIGH positions at
* the bottom or right.
*
* See also: vips_smartcrop().
*/

View File

@ -8,6 +8,10 @@
* - revised attention smartcrop
* 8/6/17
* - revised again
* 15/9/18 lovell
* - move shrink to start of processing
* 22/9/18 jcupitt
* - add low and high
*/
/*
@ -124,7 +128,8 @@ vips_smartcrop_entropy( VipsSmartcrop *smartcrop,
double right_score;
if( vips_smartcrop_score( smartcrop, in,
*left, *top, slice_width, height, &left_score ) )
*left, *top,
slice_width, height, &left_score ) )
return( -1 );
if( vips_smartcrop_score( smartcrop, in,
@ -142,7 +147,8 @@ vips_smartcrop_entropy( VipsSmartcrop *smartcrop,
double bottom_score;
if( vips_smartcrop_score( smartcrop, in,
*left, *top, width, slice_height, &top_score ) )
*left, *top,
width, slice_height, &top_score ) )
return( -1 );
if( vips_smartcrop_score( smartcrop, in,
@ -333,6 +339,7 @@ vips_smartcrop_build( VipsObject *object )
switch( smartcrop->interesting ) {
case VIPS_INTERESTING_NONE:
case VIPS_INTERESTING_LOW:
left = 0;
top = 0;
break;
@ -352,6 +359,11 @@ vips_smartcrop_build( VipsObject *object )
return( -1 );
break;
case VIPS_INTERESTING_HIGH:
left = smartcrop->in->Xsize - smartcrop->width;
top = smartcrop->in->Ysize - smartcrop->height;
break;
default:
g_assert_not_reached();
@ -363,7 +375,8 @@ vips_smartcrop_build( VipsObject *object )
}
if( vips_extract_area( smartcrop->in, &t[1],
left, top, smartcrop->width, smartcrop->height, NULL ) ||
left, top,
smartcrop->width, smartcrop->height, NULL ) ||
vips_image_write( t[1], conversion->out ) )
return( -1 );

View File

@ -99,6 +99,8 @@ typedef enum {
VIPS_INTERESTING_CENTRE,
VIPS_INTERESTING_ENTROPY,
VIPS_INTERESTING_ATTENTION,
VIPS_INTERESTING_LOW,
VIPS_INTERESTING_HIGH,
VIPS_INTERESTING_LAST
} VipsInteresting;

View File

@ -364,6 +364,8 @@ vips_interesting_get_type( void )
{VIPS_INTERESTING_CENTRE, "VIPS_INTERESTING_CENTRE", "centre"},
{VIPS_INTERESTING_ENTROPY, "VIPS_INTERESTING_ENTROPY", "entropy"},
{VIPS_INTERESTING_ATTENTION, "VIPS_INTERESTING_ATTENTION", "attention"},
{VIPS_INTERESTING_LOW, "VIPS_INTERESTING_LOW", "low"},
{VIPS_INTERESTING_HIGH, "VIPS_INTERESTING_HIGH", "high"},
{VIPS_INTERESTING_LAST, "VIPS_INTERESTING_LAST", "last"},
{0, NULL, NULL}
};