Пример #1
0
/**
 * im_ismonotonic:
 * @lut: lookup-table to test
 * @out: set non-zero if @lut is monotonic
 *
 * Test @lut for monotonicity. @out is set non-zero if @lut is monotonic.
 *
 * See also: im_tone_build_range().
 *
 * Returns: 0 on success, -1 on error
 */
int
im_ismonotonic( IMAGE *lut, int *out )
{
    IMAGE *t[2];
    INTMASK *mask;
    double m;

    if( im_check_hist( "im_ismonotonic", lut ) ||
            im_open_local_array( lut, t, 2, "im_ismonotonic", "p" ) )
        return( -1 );

    if( lut->Xsize == 1 )
        mask = im_create_imaskv( "im_ismonotonic", 1, 2, -1, 1 );
    else
        mask = im_create_imaskv( "im_ismonotonic", 2, 1, -1, 1 );
    if( !(mask = im_local_imask( lut, mask )) )
        return( -1 );
    mask->offset = 128;

    /* We want >=128 everywhere, ie. no -ve transitions.
     */
    if( im_conv( lut, t[0], mask ) ||
            im_moreeqconst( t[0], t[1], 128 ) ||
            im_min( t[1], &m ) )
        return( -1 );

    *out = m;

    return( 0 );
}
Пример #2
0
static INTMASK *
mk_convmat () {
    INTMASK *m;
    int coeffs[] = {-1, -1, -1, -1, 16,-1, -1, -1, -1};

    m = im_create_imaskv("conv.mat", 3, 3);
    check(!!m, "im_create_imaskv failed.");

    memcpy(m->coeff, coeffs, 3*3*sizeof(int));

    m->scale = 8;

    return m;
}/* mk_convmat*/
Пример #3
0
/* Some interpolators look a little soft, so we have an optional sharpening
 * stage.
 */
static INTMASK *
sharpen_filter( void )
{
	static INTMASK *mask = NULL;

	if( !mask ) {
		mask = im_create_imaskv( "sharpen.con", 3, 3, 
			-1, -1, -1, 
			-1, 32, -1, 
			-1, -1, -1 );
		mask->scale = 24;
	}

	return( mask );
}
Пример #4
0
/**
 * im_draw_smudge:
 * @image: image to smudge
 * @left: area to smudge
 * @top: area to smudge
 * @width: area to smudge
 * @height: area to smudge
 *
 * Smudge a section of @image. Each pixel in the area @left, @top, @width,
 * @height is replaced by the average of the surrounding 3x3 pixels. 
 *
 * This an inplace operation, so @image is changed. It does not thread and will
 * not work well as part of a pipeline. On 32-bit machines it will be limited
 * to 2GB images.
 *
 * See also: im_draw_line().
 *
 * Returns: 0 on success, or -1 on error.
 */
int
im_draw_smudge( VipsImage *im, int left, int top, int width, int height )
{
	Rect area, image, clipped;
	IMAGE *t[2];

	area.left = left;
	area.top = top;
	area.width = width;
	area.height = height;
	image.left = 0;
	image.top = 0;
	image.width = im->Xsize;
	image.height = im->Ysize;
	im_rect_intersectrect( &area, &image, &clipped );
	if( im_rect_isempty( &clipped ) )
		return( 0 );

	if( !blur ) {
		blur = im_create_imaskv( "im_draw_smudge", 3, 1, 1, 4, 1 );
		blur->scale = 6;
	}

	if( !(t[0] = im_open( "im_draw_smudge", "p" )) )
		return( -1 );
	if( !(t[1] = im_open_local( t[0], "im_draw_smudge", "p" )) ||
		im_convsep( im, t[0], blur ) ||
		im_extract_area( t[0], t[1], 
			clipped.left, clipped.top, 
			clipped.width, clipped.height ) ||
		im_draw_image( im, t[1], clipped.left, clipped.top ) ) {
		im_close( t[0] );
		return( -1 );
	}
	im_close( t[0] );

	return( 0 );
}