[cairo] [PATCH] Improve computation of filter scale factors

Bill Spitzak spitzak at gmail.com
Tue Apr 1 19:50:08 PDT 2014

I have had much better results using the values called alpha_x and 
alpha_y as the scale factors.

This preserves the *area* of the parallelogram. Using the bounding box 
produces excessive blur (though this appears to be using the bounding 
box of an ellipse inscribed in the parallelogram, which is better).

These are calculated from the inverse matrix (ie they get larger as the 
image is scaled smaller). I am unsure if hypot produces the inverse 
values from the forward matrix. In general I recommend using the inverse 
matrix for all calculations.

otaylor at redhat.com wrote:

> +	alpha_x = hypot (pattern->matrix.xx, pattern->matrix.xy);
> +	alpha_y = hypot (pattern->matrix.yx, pattern->matrix.yy);
> +	det = pattern->matrix.xx * pattern->matrix.yy - pattern->matrix.xy * pattern->matrix.yx;
> +
> +	/* αx, αy are non-zero, since they can only be zero if Axx=Axy=0 or Ayx=Ayy=0,
> +	 * assuming quality implementation of hypot(), and then D would be zero,
> +	 * which is not allowed for a pattern matrix. */
> +	scale_x = sqrt (fabs (det) * alpha_x / alpha_y);
> +	scale_y = sqrt (fabs (det) * alpha_y / alpha_x);

More information about the cairo mailing list