114
static GimpParamDef args[] =
116
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
117
{ GIMP_PDB_IMAGE, "image", "Input image" },
118
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
119
{ GIMP_PDB_FLOAT, "horizontal", "Horizontal radius of gaussian blur (in pixels, > 0.0)" },
120
{ GIMP_PDB_FLOAT, "vertical", "Vertical radius of gaussian blur (in pixels, > 0.0)" },
121
{ GIMP_PDB_INT32, "method", "IIR (0) or RLE (1)" }
124
static GimpParamDef args1[] =
126
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
127
{ GIMP_PDB_IMAGE, "image", "Input image (unused)" },
128
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
129
{ GIMP_PDB_FLOAT, "radius", "Radius of gaussian blur (in pixels, > 0.0)" },
130
{ GIMP_PDB_INT32, "horizontal", "Blur in horizontal direction" },
131
{ GIMP_PDB_INT32, "vertical", "Blur in vertical direction" }
134
static GimpParamDef args2[] =
136
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
137
{ GIMP_PDB_IMAGE, "image", "Input image" },
138
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
139
{ GIMP_PDB_FLOAT, "horizontal", "Horizontal radius of gaussian blur (in pixels, > 0.0)" },
140
{ GIMP_PDB_FLOAT, "vertical", "Vertical radius of gaussian blur (in pixels, > 0.0)" }
143
gimp_install_procedure ("plug_in_gauss",
144
"Applies a gaussian blur to the specified drawable.",
129
static const GimpParamDef args[] =
131
{ GIMP_PDB_INT32, "run-mode", "Interactive, non-interactive" },
132
{ GIMP_PDB_IMAGE, "image", "Input image" },
133
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
134
{ GIMP_PDB_FLOAT, "horizontal", "Horizontal radius of gaussian blur (in pixels, > 0.0)" },
135
{ GIMP_PDB_FLOAT, "vertical", "Vertical radius of gaussian blur (in pixels, > 0.0)" },
136
{ GIMP_PDB_INT32, "method", "IIR (0) or RLE (1)" }
139
static const GimpParamDef args1[] =
141
{ GIMP_PDB_INT32, "run-mode", "Interactive, non-interactive" },
142
{ GIMP_PDB_IMAGE, "image", "Input image (unused)" },
143
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
144
{ GIMP_PDB_FLOAT, "radius", "Radius of gaussian blur (in pixels, > 0.0)" },
145
{ GIMP_PDB_INT32, "horizontal", "Blur in horizontal direction" },
146
{ GIMP_PDB_INT32, "vertical", "Blur in vertical direction" }
149
static const GimpParamDef args2[] =
151
{ GIMP_PDB_INT32, "run-mode", "Interactive, non-interactive" },
152
{ GIMP_PDB_IMAGE, "image", "Input image" },
153
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
154
{ GIMP_PDB_FLOAT, "horizontal", "Horizontal radius of gaussian blur (in pixels, > 0.0)" },
155
{ GIMP_PDB_FLOAT, "vertical", "Vertical radius of gaussian blur (in pixels, > 0.0)" }
158
gimp_install_procedure (GAUSS_PROC,
159
N_("Simplest, most commonly used way of blurring"),
145
160
"Applies a gaussian blur to the drawable, with "
146
161
"specified radius of affect. The standard deviation "
147
162
"of the normal distribution used to modify pixel "
608
gauss (GimpDrawable *drawable,
634
* run_length_encode (src, rle, pix, dist, width, border, pack);
636
* Copy 'width' 8bit pixels from 'src' to 'pix' and extend both sides
637
* by 'border' pixels so 'pix[]' is filled from '-border' to 'width+border-1'.
639
* 'dist' is the distance between the pixels in 'src'.
641
* If 'pack' is TRUE, then 'rle' is filled with a run-length encoding
642
* of the pixels. In plain english, that means that rle[i] gives the
643
* number of times the same pixel is found pix[i], pix[i+1], ... A
644
* standalone pixel has a rle value of 1.
646
* The function returns the number of times 2 identical consecutive pixels
649
* Note: The function must be inlined to insure that all tests on
650
* 'pack' are efficiently resolved by the compiler (they are in
651
* the critical loop). As a consequence, the function should
652
* only be called with known constant value for 'pack'. In the
653
* current implementation, 'pack' is always TRUE but it might be
654
* more efficient to have an 'adaptive' algorithm that switches
655
* to FALSE when the run-length is innefficient.
658
run_length_encode (const guchar *src,
661
gint dist, /* distance between 2 src pixels */
671
src += dist * (width - 1);
674
rle += width + border - 1;
676
pix += width + border - 1;
681
/* the 'end' border */
682
for (i = 0; i < border; i++)
691
/* the real pixels */
692
for (i = 0; i < width; i++)
715
/* the start pixels */
716
for (i = 0; i < border; i++)
730
do_encoded_lre (const gint *enc,
742
for (col = 0; col < width; col++)
750
gint start = - length;
752
rpt = &enc[col + start];
753
pix = &src[col + start];
763
val += pix[0] * (s2-s1);
771
val += pix[0] * (csum[length] - s1);
773
*dest = val / ctotal;
780
do_full_lre (const gint *src,
790
for (col = 0; col < width; col++)
794
const gint *c = &curve[0];
800
/* The central point is a special case since it should only be
811
/* Processing multiple points in a single iteration should be
812
* faster but is not strictly required.
813
* Some precise benchmarking will be needed to figure out
814
* if this is really interesting.
818
val += (x1[0] + x2[-0]) * c[0];
819
val += (x1[1] + x2[-1]) * c[1];
820
val += (x1[2] + x2[-2]) * c[2];
821
val += (x1[3] + x2[-3]) * c[3];
822
val += (x1[4] + x2[-4]) * c[4];
823
val += (x1[5] + x2[-5]) * c[5];
824
val += (x1[6] + x2[-6]) * c[6];
825
val += (x1[7] + x2[-7]) * c[7];
835
val += (x1[0] + x2[-0]) * c[0];
836
val += (x1[1] + x2[-1]) * c[1];
837
val += (x1[2] + x2[-2]) * c[2];
838
val += (x1[3] + x2[-3]) * c[3];
845
/* Only that final loop is strictly required */
849
/* process the pixels at the distance i before and after the
850
* central point. They must have the same coefficient
852
val += (x1[0] + x2[-0]) * c[0];
859
*dest = val / ctotal;
866
gauss_iir (GimpDrawable *drawable,
870
guchar *preview_buffer,
614
876
GimpPixelRgn src_rgn, dest_rgn;
619
guchar *src, *sp, *sp_p, *sp_m;
880
guchar *src, *sp_p, *sp_m;
622
881
gdouble n_p[5], n_m[5];
623
882
gdouble d_p[5], d_m[5];
624
883
gdouble bd_p[5], bd_m[5];
625
884
gdouble *val_p = NULL;
626
885
gdouble *val_m = NULL;
627
886
gdouble *vp, *vm;
630
888
gint row, col, b;
633
891
gint initial_p[4];
634
892
gint initial_m[4];
898
direct = (preview_buffer == NULL);
900
bytes = drawable->bpp;
901
has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
903
val_p = g_new (gdouble, MAX (width, height) * bytes);
904
val_m = g_new (gdouble, MAX (width, height) * bytes);
906
src = g_new (guchar, MAX (width, height) * bytes);
907
dest = g_new (guchar, MAX (width, height) * bytes);
909
gimp_pixel_rgn_init (&src_rgn,
910
drawable, 0, 0, drawable->width, drawable->height,
914
gimp_pixel_rgn_init (&dest_rgn,
915
drawable, 0, 0, drawable->width, drawable->height,
921
max_progress = (horz <= 0.0) ? 0 : width * height * horz;
922
max_progress += (vert <= 0.0) ? 0 : width * height * vert;
925
/* First the vertical pass */
928
vert = fabs (vert) + 1.0;
929
std_dev = sqrt (-(vert * vert) / (2 * log (1.0 / 255.0)));
931
/* We do not want too many progress updates because they
932
* can slow down the processing significantly for very
935
progress_step = width / 100;
936
if (progress_step < 5)
939
/* derive the constants for calculating the gaussian
943
find_iir_constants (n_p, n_m, d_p, d_m, bd_p, bd_m, std_dev);
945
for (col = 0; col < width; col++)
947
memset (val_p, 0, height * bytes * sizeof (gdouble));
948
memset (val_m, 0, height * bytes * sizeof (gdouble));
950
gimp_pixel_rgn_get_col (&src_rgn, src, col + x1, y1, height);
953
multiply_alpha (src, height, bytes);
956
sp_m = src + (height - 1) * bytes;
958
vm = val_m + (height - 1) * bytes;
960
/* Set up the first vals */
961
for (i = 0; i < bytes; i++)
963
initial_p[i] = sp_p[i];
964
initial_m[i] = sp_m[i];
967
for (row = 0; row < height; row++)
969
gdouble *vpptr, *vmptr;
970
terms = (row < 4) ? row : 4;
972
for (b = 0; b < bytes; b++)
974
vpptr = vp + b; vmptr = vm + b;
975
for (i = 0; i <= terms; i++)
977
*vpptr += n_p[i] * sp_p[(-i * bytes) + b] - d_p[i] * vp[(-i * bytes) + b];
978
*vmptr += n_m[i] * sp_m[(i * bytes) + b] - d_m[i] * vm[(i * bytes) + b];
980
for (j = i; j <= 4; j++)
982
*vpptr += (n_p[j] - bd_p[j]) * initial_p[b];
983
*vmptr += (n_m[j] - bd_m[j]) * initial_m[b];
993
transfer_pixels (val_p, val_m, dest, bytes, height);
997
separate_alpha (dest, height, bytes);
1001
gimp_pixel_rgn_set_col(&dest_rgn, dest, col + x1, y1, height);
1003
progress += height * vert;
1004
if ((col % progress_step) == 0)
1005
gimp_progress_update (progress / max_progress);
1009
for (row = 0; row < height; row++)
1010
memcpy (preview_buffer + (row * width + col) * bytes,
1016
/* prepare for the horizontal pass */
1017
gimp_pixel_rgn_init (&src_rgn,
1020
drawable->width, drawable->height,
1025
gimp_pixel_rgn_get_rect (&src_rgn,
1031
/* Now the horizontal pass */
1035
/* We do not want too many progress updates because they
1036
* can slow down the processing significantly for very
1039
progress_step = height / 100;
1041
if (progress_step < 5)
1044
horz = fabs (horz) + 1.0;
1048
std_dev = sqrt (-(horz * horz) / (2 * log (1.0 / 255.0)));
1050
/* derive the constants for calculating the gaussian
1053
find_iir_constants (n_p, n_m, d_p, d_m, bd_p, bd_m, std_dev);
1058
for (row = 0; row < height; row++)
1061
memset (val_p, 0, width * bytes * sizeof (gdouble));
1062
memset (val_m, 0, width * bytes * sizeof (gdouble));
1066
gimp_pixel_rgn_get_row (&src_rgn, src, x1, row + y1, width);
1071
preview_buffer + row * width * bytes,
1077
multiply_alpha (src, width, bytes);
1081
sp_m = src + (width - 1) * bytes;
1083
vm = val_m + (width - 1) * bytes;
1085
/* Set up the first vals */
1086
for (i = 0; i < bytes; i++)
1088
initial_p[i] = sp_p[i];
1089
initial_m[i] = sp_m[i];
1092
for (col = 0; col < width; col++)
1094
gdouble *vpptr, *vmptr;
1096
terms = (col < 4) ? col : 4;
1098
for (b = 0; b < bytes; b++)
1100
vpptr = vp + b; vmptr = vm + b;
1102
for (i = 0; i <= terms; i++)
1104
*vpptr += n_p[i] * sp_p[(-i * bytes) + b] -
1105
d_p[i] * vp[(-i * bytes) + b];
1106
*vmptr += n_m[i] * sp_m[(i * bytes) + b] -
1107
d_m[i] * vm[(i * bytes) + b];
1109
for (j = i; j <= 4; j++)
1111
*vpptr += (n_p[j] - bd_p[j]) * initial_p[b];
1112
*vmptr += (n_m[j] - bd_m[j]) * initial_m[b];
1122
transfer_pixels (val_p, val_m, dest, bytes, width);
1125
separate_alpha (dest, width, bytes);
1129
gimp_pixel_rgn_set_row (&dest_rgn, dest, x1, row + y1, width);
1131
progress += width * horz;
1133
if ((row % progress_step) == 0)
1134
gimp_progress_update (progress / max_progress);
1138
memcpy (preview_buffer + row * width * bytes,
1145
/* free up buffers */
1156
gauss_rle (GimpDrawable *drawable,
1160
guchar *preview_buffer,
1166
GimpPixelRgn src_rgn, dest_rgn;
1172
gdouble progress, max_progress;
643
gint initial_pp, initial_mm;
644
guchar *preview_buffer1 = NULL;
645
guchar *preview_buffer2 = NULL;
1181
direct = (preview_buffer == NULL);
1183
bytes = drawable->bpp;
1184
has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
1186
src = g_new (guchar, MAX (width, height) * bytes);
1187
dest = g_new (guchar, MAX (width, height) * bytes);
1189
gimp_pixel_rgn_init (&src_rgn,
1190
drawable, 0, 0, drawable->width, drawable->height,
1194
gimp_pixel_rgn_init (&dest_rgn,
1195
drawable, 0, 0, drawable->width, drawable->height,
1199
max_progress = (horz <= 0.0) ? 0 : width * height * horz;
1200
max_progress += (vert <= 0.0) ? 0 : width * height * vert;
1203
/* First the vertical pass */
1209
vert = fabs (vert) + 1.0;
1210
std_dev = sqrt (-(vert * vert) / (2 * log (1.0 / 255.0)));
1212
/* Insure that we do not have too many progress updates for
1213
* images with a lot of rows or columns
1215
progress_step = width / 150;
1217
if (progress_step < 5)
1220
make_rle_curve (std_dev, &curve, &length, &sum, &total);
1222
rle = g_new (gint, height + 2 * length);
1223
rle += length; /* rle[] extends from -length to height+length-1 */
1225
pix = g_new (gint, height + 2 * length);
1226
pix += length; /* pix[] extends from -length to height+length-1 */
1228
for (col = 0; col < width; col++)
1231
gimp_pixel_rgn_get_col (&src_rgn, src, col + x1, y1, height);
1234
multiply_alpha (src, height, bytes);
1236
for (b = 0; b < bytes; b++)
1238
gint same = run_length_encode (src + b, rle, pix, bytes,
1239
height, length, TRUE);
1241
if (same > (3 * height) / 4)
1243
/* encoded_rle is only fastest if there are a lot of
1246
do_encoded_lre (rle, pix, dest + b, height, length, bytes,
1251
/* else a full but more simple algorithm is better */
1252
do_full_lre (pix, dest + b, height, length, bytes,
1258
separate_alpha (dest, height, bytes);
1262
gimp_pixel_rgn_set_col (&dest_rgn, dest, col + x1, y1, height);
1264
progress += height * vert;
1265
if ((col % progress_step) == 0)
1266
gimp_progress_update (progress / max_progress);
1270
for (row = 0; row < height; row++)
1271
memcpy (preview_buffer + (row * width + col) * bytes,
1279
g_free (rle - length);
1280
g_free (pix - length);
1282
/* prepare for the horizontal pass */
1283
gimp_pixel_rgn_init (&src_rgn,
1284
drawable, 0, 0, drawable->width, drawable->height,
1289
gimp_pixel_rgn_get_rect (&src_rgn,
1290
preview_buffer, x1, y1, width, height);
1293
/* Now the horizontal pass */
1299
/* Insure that we do not have too many progress updates for
1300
* images with a lot of rows or columns
1302
progress_step = height / 150;
1303
if (progress_step < 5) {
1307
horz = fabs (horz) + 1.0;
1309
/* euse the same curve if possible else recompute a new one */
1313
std_dev = sqrt (-(horz * horz) / (2 * log (1.0 / 255.0)));
1315
if (curve != NULL) {
1316
free_rle_curve(curve, length, sum);
1319
make_rle_curve(std_dev, &curve, &length, &sum, &total);
1324
rle = g_new (gint, width+2*length);
1325
rle += length; /* so rle[] extends from -width to width+length-1 */
1327
pix = g_new (gint, width+2*length);
1328
pix += length; /* so pix[] extends from -width to width+length-1 */
1330
for (row = 0; row < height; row++)
1334
gimp_pixel_rgn_get_row (&src_rgn, src, x1, row + y1, width);
1339
preview_buffer + row * width * bytes,
1344
multiply_alpha (src, width, bytes);
1346
for (b = 0; b < bytes; b++)
1348
gint same = run_length_encode (src + b, rle, pix, bytes,
1349
width, length, TRUE);
1351
if (same > (3 * width) / 4)
1353
/* encoded_rle is only fastest if there are a lot of
1356
do_encoded_lre (rle, pix, dest + b, width, length, bytes,
1361
/* else a full but more simple algorithm is better */
1362
do_full_lre (pix, dest + b, width, length, bytes,
1369
separate_alpha (dest, width, bytes);
1373
gimp_pixel_rgn_set_row (&dest_rgn, dest, x1, row + y1, width);
1375
progress += width * horz;
1376
if ((row % progress_step) == 0)
1377
gimp_progress_update (progress / max_progress);
1381
memcpy (preview_buffer + row * width * bytes,
1387
g_free (rle - length);
1388
g_free (pix - length);
1392
free_rle_curve (curve, length, sum);
1400
gauss (GimpDrawable *drawable,
1407
gint x1, y1, x2, y2;
1409
guchar *preview_buffer;
648
1412
* IIR goes wrong if the blur radius is less than 1, so we silently
671
1440
width = (x2 - x1);
672
1441
height = (y2 - y1);
675
if (width < 1 || height < 1)
678
bytes = drawable->bpp;
679
has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
684
val_p = g_new (gdouble, MAX (width, height) * bytes);
685
val_m = g_new (gdouble, MAX (width, height) * bytes);
689
buf = g_new (gint, MAX (width, height) * 2);
693
src = g_new (guchar, MAX (width, height) * bytes);
694
dest = g_new (guchar, MAX (width, height) * bytes);
696
gimp_pixel_rgn_init (&src_rgn,
697
drawable, 0, 0, drawable->width, drawable->height,
701
preview_buffer1 = g_new (guchar, width * height * bytes);
702
preview_buffer2 = g_new (guchar, width * height * bytes);
1443
if (width < 1 || height < 1)
1446
preview_buffer = NULL;
1451
if (method == BLUR_IIR)
1452
gauss_iir (drawable,
1453
horz, vert, method, preview_buffer, x1, y1, width, height);
706
gimp_pixel_rgn_init (&dest_rgn,
707
drawable, 0, 0, drawable->width, drawable->height,
712
max_progress = (horz <= 0.0 ) ? 0 : width * height * horz;
713
max_progress += (vert <= 0.0 ) ? 0 : width * height * vert;
716
/* First the vertical pass */
719
vert = fabs (vert) + 1.0;
720
std_dev = sqrt (-(vert * vert) / (2 * log (1.0 / 255.0)));
725
/* derive the constants for calculating the gaussian
728
find_constants (n_p, n_m, d_p, d_m, bd_p, bd_m, std_dev);
732
curve = make_curve (std_dev, &length);
733
sum = g_new (gint, 2 * length + 1);
737
for (i = 1; i <= length*2; i++)
738
sum[i] = curve[i-length-1] + sum[i-1];
741
total = sum[length] - sum[-length];
745
for (col = 0; col < width; col++)
750
memset (val_p, 0, height * bytes * sizeof (gdouble));
751
memset (val_m, 0, height * bytes * sizeof (gdouble));
758
gimp_pixel_rgn_get_col (&src_rgn, src, col + x1, y1, height);
761
multiply_alpha (src, height, bytes);
767
sp_m = src + (height - 1) * bytes;
769
vm = val_m + (height - 1) * bytes;
771
/* Set up the first vals */
772
for (i = 0; i < bytes; i++)
774
initial_p[i] = sp_p[i];
775
initial_m[i] = sp_m[i];
778
for (row = 0; row < height; row++)
780
gdouble *vpptr, *vmptr;
781
terms = (row < 4) ? row : 4;
783
for (b = 0; b < bytes; b++)
785
vpptr = vp + b; vmptr = vm + b;
786
for (i = 0; i <= terms; i++)
788
*vpptr += n_p[i] * sp_p[(-i * bytes) + b] -
789
d_p[i] * vp[(-i * bytes) + b];
790
*vmptr += n_m[i] * sp_m[(i * bytes) + b] -
791
d_m[i] * vm[(i * bytes) + b];
793
for (j = i; j <= 4; j++)
795
*vpptr += (n_p[j] - bd_p[j]) * initial_p[b];
796
*vmptr += (n_m[j] - bd_m[j]) * initial_m[b];
806
transfer_pixels (val_p, val_m, dest, bytes, height);
813
for (b = 0; b < bytes; b++)
816
initial_mm = sp[(height-1) * bytes + b];
818
/* Determine a run-length encoded version of the row */
819
run_length_encode (sp + b, buf, bytes, height);
821
for (row = 0; row < height; row++)
823
start = (row < length) ? -row : -length;
824
end = (height <= (row + length) ?
825
(height - row - 1) : length);
829
bb = buf + (row + i) * 2;
831
if (start != -length)
832
val += initial_pp * (sum[start] - sum[-length]);
840
val += bb[1] * (sum[i] - sum[start]);
846
val += initial_mm * (sum[length] - sum[end]);
848
dp[row * bytes + b] = val / total;
855
separate_alpha (src, height, bytes);
859
for (row = 0 ; row < height ; row++)
860
memcpy (preview_buffer1 + (row * width + col) * bytes,
866
gimp_pixel_rgn_set_col (&dest_rgn, dest, col + x1, y1, height);
868
progress += height * vert;
870
gimp_progress_update (progress / max_progress);
874
/* prepare for the horizontal pass */
875
gimp_pixel_rgn_init (&src_rgn,
876
drawable, 0, 0, drawable->width, drawable->height,
881
gimp_pixel_rgn_get_rect (&src_rgn,
882
preview_buffer1, x1, y1, width, height);
885
/* Now the horizontal pass */
888
horz = fabs (horz) + 1.0;
892
std_dev = sqrt (-(horz * horz) / (2 * log (1.0 / 255.0)));
897
/* derive the constants for calculating the gaussian
900
find_constants (n_p, n_m, d_p, d_m, bd_p, bd_m, std_dev);
904
curve = make_curve (std_dev, &length);
905
sum = g_new (gint, 2 * length + 1);
909
for (i = 1; i <= length*2; i++)
910
sum[i] = curve[i-length-1] + sum[i-1];
913
total = sum[length] - sum[-length];
918
for (row = 0; row < height; row++)
923
memset (val_p, 0, width * bytes * sizeof (gdouble));
924
memset (val_m, 0, width * bytes * sizeof (gdouble));
934
preview_buffer1 + row * width * bytes,
939
gimp_pixel_rgn_get_row (&src_rgn, src, x1, row + y1, width);
943
multiply_alpha (dest, width, bytes);
949
sp_m = src + (width - 1) * bytes;
951
vm = val_m + (width - 1) * bytes;
953
/* Set up the first vals */
954
for (i = 0; i < bytes; i++)
956
initial_p[i] = sp_p[i];
957
initial_m[i] = sp_m[i];
960
for (col = 0; col < width; col++)
962
gdouble *vpptr, *vmptr;
963
terms = (col < 4) ? col : 4;
965
for (b = 0; b < bytes; b++)
967
vpptr = vp + b; vmptr = vm + b;
968
for (i = 0; i <= terms; i++)
970
*vpptr += n_p[i] * sp_p[(-i * bytes) + b] -
971
d_p[i] * vp[(-i * bytes) + b];
972
*vmptr += n_m[i] * sp_m[(i * bytes) + b] -
973
d_m[i] * vm[(i * bytes) + b];
975
for (j = i; j <= 4; j++)
977
*vpptr += (n_p[j] - bd_p[j]) * initial_p[b];
978
*vmptr += (n_m[j] - bd_m[j]) * initial_m[b];
988
transfer_pixels (val_p, val_m, dest, bytes, width);
995
for (b = 0; b < bytes; b++)
998
initial_mm = sp[(width-1) * bytes + b];
1000
/* Determine a run-length encoded version of the row */
1001
run_length_encode (sp + b, buf, bytes, width);
1003
for (col = 0; col < width; col++)
1005
start = (col < length) ? -col : -length;
1006
end = (width <= (col + length)) ? (width - col - 1) : length;
1010
bb = buf + (col + i) * 2;
1012
if (start != -length)
1013
val += initial_pp * (sum[start] - sum[-length]);
1021
val += bb[1] * (sum[i] - sum[start]);
1027
val += initial_mm * (sum[length] - sum[end]);
1029
dp[col * bytes + b] = val / total;
1036
separate_alpha (dest, width, bytes);
1040
memcpy (preview_buffer2 + row * width * bytes,
1046
gimp_pixel_rgn_set_row (&dest_rgn, dest, x1, row + y1, width);
1048
progress += width * horz;
1050
gimp_progress_update (progress / max_progress);
1056
memcpy (preview_buffer2, preview_buffer1, width * height * bytes);
1455
gauss_rle (drawable,
1456
horz, vert, method, preview_buffer, x1, y1, width, height);
1061
1460
gimp_preview_draw_buffer (GIMP_PREVIEW (preview),
1062
preview_buffer2, width * bytes);
1063
g_free (preview_buffer1);
1064
g_free (preview_buffer2);
1461
preview_buffer, width * drawable->bpp);
1462
g_free (preview_buffer);
1129
1521
div = sqrt(2 * G_PI) * std_dev;
1130
constants [0] = -1.783 / std_dev;
1131
constants [1] = -1.723 / std_dev;
1132
constants [2] = 0.6318 / std_dev;
1133
constants [3] = 1.997 / std_dev;
1134
constants [4] = 1.6803 / div;
1135
constants [5] = 3.735 / div;
1136
constants [6] = -0.6803 / div;
1137
constants [7] = -0.2598 / div;
1522
x0 = -1.783 / std_dev;
1523
x1 = -1.723 / std_dev;
1524
x2 = 0.6318 / std_dev;
1525
x3 = 1.997 / std_dev;
1139
n_p [0] = constants[4] + constants[6];
1140
n_p [1] = exp (constants[1]) *
1141
(constants[7] * sin (constants[3]) -
1142
(constants[6] + 2 * constants[4]) * cos (constants[3])) +
1143
exp (constants[0]) *
1144
(constants[5] * sin (constants[2]) -
1145
(2 * constants[6] + constants[4]) * cos (constants[2]));
1146
n_p [2] = 2 * exp (constants[0] + constants[1]) *
1147
((constants[4] + constants[6]) * cos (constants[3]) * cos (constants[2]) -
1148
constants[5] * cos (constants[3]) * sin (constants[2]) -
1149
constants[7] * cos (constants[2]) * sin (constants[3])) +
1150
constants[6] * exp (2 * constants[0]) +
1151
constants[4] * exp (2 * constants[1]);
1152
n_p [3] = exp (constants[1] + 2 * constants[0]) *
1153
(constants[7] * sin (constants[3]) - constants[6] * cos (constants[3])) +
1154
exp (constants[0] + 2 * constants[1]) *
1155
(constants[5] * sin (constants[2]) - constants[4] * cos (constants[2]));
1532
n_p [1] = (exp(x1)*(x7*sin(x3)-(x6+2*x4)*cos(x3)) +
1533
exp(x0)*(x5*sin(x2) - (2*x6+x4)*cos (x2)));
1534
n_p [2] = (2 * exp(x0+x1) *
1535
((x4+x6)*cos(x3)*cos(x2) - x5*cos(x3)*sin(x2) -
1536
x7*cos(x2)*sin(x3)) +
1537
x6*exp(2*x0) + x4*exp(2*x1));
1538
n_p [3] = (exp(x1+2*x0) * (x7*sin(x3) - x6*cos(x3)) +
1539
exp(x0+2*x1) * (x5*sin(x2) - x4*cos(x2)));
1159
d_p [1] = -2 * exp (constants[1]) * cos (constants[3]) -
1160
2 * exp (constants[0]) * cos (constants[2]);
1161
d_p [2] = 4 * cos (constants[3]) * cos (constants[2]) * exp (constants[0] + constants[1]) +
1162
exp (2 * constants[1]) + exp (2 * constants[0]);
1163
d_p [3] = -2 * cos (constants[2]) * exp (constants[0] + 2 * constants[1]) -
1164
2 * cos (constants[3]) * exp (constants[1] + 2 * constants[0]);
1165
d_p [4] = exp (2 * constants[0] + 2 * constants[1]);
1543
d_p [1] = -2 * exp(x1) * cos(x3) - 2 * exp(x0) * cos (x2);
1544
d_p [2] = 4 * cos(x3) * cos(x2) * exp(x0 + x1) + exp(2 * x1) + exp(2 * x0);
1545
d_p [3] = -2 * cos(x2) * exp(x0 + 2*x1) - 2*cos(x3) * exp(x1 + 2*x0);
1546
d_p [4] = exp(2*x0 + 2*x1);
1167
1548
for (i = 0; i <= 4; i++)
1171
1553
for (i = 1; i <= 4; i++)
1172
n_m [i] = n_p[i] - d_p[i] * n_p[0];
1554
n_m[i] = n_p[i] - d_p[i] * n_p[0];
1175
1557
gdouble sum_n_p, sum_n_m, sum_d;