Bill Skaggs <weskaggs@primate.ucdavis.edu>

* app/paint-funcs/scale-funcs.[ch]:  apply patch from GG
	to improve accuracy of Lanczos, from bug #358481.
This commit is contained in:
William Skaggs 2006-10-11 16:24:43 +00:00
parent 56617a9974
commit 65a8698ed5
3 changed files with 21 additions and 7 deletions

View File

@ -1,3 +1,8 @@
2006-10-11 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* app/paint-funcs/scale-funcs.[ch]: apply patch from GG
to improve accuracy of Lanczos, from bug #358481.
2006-10-11 Sven Neumann <sven@gimp.org>
* configure.in: bumped version to 2.3.13.

View File

@ -868,13 +868,14 @@ inv_lin_trans (const gdouble *t,
}
/* allocate and fill lookup table of Lanczos windowed sinc funtion */
gdouble *
/* allocate and fill lookup table of Lanczos windowed sinc function */
/* use gfloat since errors due to granularity of array far exceed data precision*/
gfloat *
create_lanczos_lookup (void)
{
const gdouble dx = (gdouble) LANCZOS_WIDTH / (gdouble) (LANCZOS_SAMPLES - 1);
gdouble *lookup = g_new (gdouble, LANCZOS_SAMPLES);
gfloat *lookup = g_new (gfloat, LANCZOS_SAMPLES);
gdouble x = 0.0;
gint i;
@ -895,7 +896,7 @@ scale_region_lanczos (PixelRegion *srcPR,
gpointer progress_data)
{
gdouble *lanczos = NULL; /* Lanczos lookup table */
gfloat *lanczos = NULL; /* Lanczos lookup table */
gdouble x_kernel[LANCZOS_WIDTH2], /* 1-D kernels of Lanczos window coeffs */
y_kernel[LANCZOS_WIDTH2];
gdouble kx_sum, ky_sum; /* sums of Lanczos kernel coeffs */

View File

@ -21,9 +21,9 @@
#define EPSILON (0.0001) /* arbitary small number for avoiding zero */
#define LANCZOS_SPP (1000) /* number of data pts per unit x in lookup table */
#define LANCZOS_SPP (4000) /* number of data pts per unit x in lookup table */
#define LANCZOS_MIN (1.0/LANCZOS_SPP)
#define LANCZOS_WIDTH (3)
#define LANCZOS_WIDTH (3) /* 3 for Lanczos3 code, for L4 prefer DUAL_LANCZOS below */
#define LANCZOS_WIDTH2 (1 + (LANCZOS_WIDTH * 2))
#define LANCZOS_SAMPLES (LANCZOS_SPP * (LANCZOS_WIDTH + 1))
@ -34,7 +34,15 @@ void scale_region (PixelRegion *srcPR,
GimpProgressFunc progress_callback,
gpointer progress_data);
gdouble * create_lanczos_lookup (void);
gfloat * create_lanczos_lookup (void);
#endif /* __SCALE_FUNCS_H__ */
/* determining LANCZOS_SPP value
1000 points per unit will produce typically 1 bit of error per channel on a Lanczos3 window
4000 should not produce a detectable error caused by lookup table size.on 8b colours ie 24bit RGB
this req 80kB of memory comparable to a small 250x150 px image. Filling the array is a small part of
the time required for the transform.
This will need reviewing when GIMP handles images with more bytes per pixel.
*/