Ejemplo n.º 1
0
/* Process a buffer of data.
 */
static void
vips_LCh2Lab_line( VipsColour *colour, VipsPel *out, VipsPel **in, int width )
{		
	float * restrict p = (float *) in[0];
	float * restrict q = (float *) out;

	int x;

	for( x = 0; x < width; x++ ) {
		float L = p[0];
		float C = p[1];
		float h = p[2];
		float a, b;

		p += 3;

		a = C * cos( VIPS_RAD( h ) );
		b = C * sin( VIPS_RAD( h ) );

		q[0] = L;
		q[1] = a;
		q[2] = b;

		q += 3;
	}
}
Ejemplo n.º 2
0
static int
vips_similarity_build( VipsObject *object )
{
	VipsResample *resample = VIPS_RESAMPLE( object );
	VipsSimilarity *similarity = (VipsSimilarity *) object;

	VipsImage **t = (VipsImage **) 
		vips_object_local_array( object, 4 );

	double a, b, c, d; 

	if( VIPS_OBJECT_CLASS( vips_similarity_parent_class )->build( object ) )
		return( -1 );

	a = similarity->scale * cos( VIPS_RAD( similarity->angle ) ); 
	b = sin( VIPS_RAD( similarity->angle ) );
	c = -b;
	d = a;

	if( vips_affine( resample->in, &t[0], a, b, c, d, 
		"interpolate", similarity->interpolate,
		"odx", similarity->odx,
		"ody", similarity->ody,
		"idx", similarity->idx,
		"idy", similarity->idy,
		NULL ) ||
		vips_image_write( t[0], resample->out ) )
		return( -1 ); 

	return( 0 );
}
Ejemplo n.º 3
0
static int
vips_similarity_build( VipsObject *object )
{
	VipsResample *resample = VIPS_RESAMPLE( object );
	VipsSimilarity *similarity = (VipsSimilarity *) object;

	VipsImage **t = (VipsImage **) 
		vips_object_local_array( object, 4 );

	if( VIPS_OBJECT_CLASS( vips_similarity_parent_class )->build( object ) )
		return( -1 );

	/* Use vips_reduce(), if we can.
	 */
	if( similarity->interpolate && 
		strcmp( VIPS_OBJECT_GET_CLASS( similarity->interpolate )->
			nickname, "bicubic" ) == 0 &&
		similarity->angle == 0.0 &&
		similarity->idx == 0.0 &&
		similarity->idy == 0.0 &&
		similarity->odx == 0.0 &&
		similarity->ody == 0.0 ) {
		if( vips_reduce( resample->in, &t[0], 
			1.0 / similarity->scale, 
			1.0 / similarity->scale, NULL ) )  
			return( -1 );
	}
	else {
		double a = similarity->scale * 
			cos( VIPS_RAD( similarity->angle ) ); 
		double b = similarity->scale * 
			-sin( VIPS_RAD( similarity->angle ) );
		double c = -b;
		double d = a;

		if( vips_affine( resample->in, &t[0], a, b, c, d, 
			"interpolate", similarity->interpolate,
			"odx", similarity->odx,
			"ody", similarity->ody,
			"idx", similarity->idx,
			"idy", similarity->idy,
			NULL ) )
			return( -1 );
	}

	if( vips_image_write( t[0], resample->out ) )
		return( -1 ); 

	return( 0 );
}
Ejemplo n.º 4
0
/**
 * vips_col_Ch2hcmc:
 * @C: Chroma
 * @h: Hue (degrees)
 *
 * Calculate hcmc from C and h.
 *
 * Returns: hcmc.
 */
float
vips_col_Ch2hcmc( float C, float h )
{	
	float P, D, f, g;
	float k4, k5, k6, k7, k8;
	float hcmc;

	if( h < 49.1 ) {
		k4 = 133.87;
		k5 = -134.5;
		k6 = -.924;
		k7 = 1.727;
		k8 = 340.0;
	}
	else if( h < 110.1 ) {
		k4 = 11.78;
		k5 = -12.7;
		k6 = -.218;
		k7 = 2.12;
		k8 = 333.0;
	}
	else if( h < 269.6 ) {
		k4 = 13.87;
		k5 = 10.93;
		k6 = 0.14;
		k7 = 1.0;
		k8 = -83.0;
	}
	else {
		k4 = .14;
		k5 = 5.23;
		k6 = .17;
		k7 = 1.61;
		k8 = 233.0;
	}

	P = cos( VIPS_RAD( k8 + k7 * h ) );
	D = k4 + k5 * P * pow( fabs( P ), k6 );
	g = C * C * C * C;
	f = sqrt( g / (g + 1900.0) );
	hcmc = h + D * f;

	return( hcmc );
}
Ejemplo n.º 5
0
static int
vips_similarity_build( VipsObject *object )
{
	VipsResample *resample = VIPS_RESAMPLE( object );
	VipsSimilarity *similarity = (VipsSimilarity *) object;
	VipsImage **t = (VipsImage **) 
		vips_object_local_array( object, 4 );

	gboolean handled;

	if( VIPS_OBJECT_CLASS( vips_similarity_parent_class )->build( object ) )
		return( -1 );

	handled = FALSE;

	/* Use vips_reduce(), if we can.
	 */
	if( similarity->interpolate &&
		similarity->angle == 0.0 &&
		similarity->idx == 0.0 &&
		similarity->idy == 0.0 &&
		similarity->odx == 0.0 &&
		similarity->ody == 0.0 ) {
		const char *nickname = VIPS_OBJECT_GET_CLASS( 
			similarity->interpolate )->nickname;

		int i; 

		for( i = 0; i < VIPS_NUMBER( vips_similarity_kernel ); i++ ) {
			VipsInterpolateKernel *ik = &vips_similarity_kernel[i];

			if( strcmp( nickname, ik->nickname ) == 0 ) {
				if( vips_reduce( resample->in, &t[0], 
					1.0 / similarity->scale, 
					1.0 / similarity->scale, 
					"kernel", ik->kernel,
					NULL ) )
					return( -1 );

				handled = TRUE;
				break;
			}
		}
	}

	if( !handled ) { 
		double a = similarity->scale * 
			cos( VIPS_RAD( similarity->angle ) ); 
		double b = similarity->scale * 
			-sin( VIPS_RAD( similarity->angle ) );
		double c = -b;
		double d = a;

		if( vips_affine( resample->in, &t[0], a, b, c, d, 
			"interpolate", similarity->interpolate,
			"odx", similarity->odx,
			"ody", similarity->ody,
			"idx", similarity->idx,
			"idy", similarity->idy,
			NULL ) )
			return( -1 );
	}

	if( vips_image_write( t[0], resample->out ) )
		return( -1 ); 

	return( 0 );
}