mirror of
https://github.com/scottdraves/flam3.git
synced 2025-01-21 13:30:04 -05:00
changed flam3_colorhist to take a random context as an argument rather than creating a new one each time. Also optimized the loop to only generate the precalc flags once and create the xform distrib array once.
git-svn-id: https://flam3.googlecode.com/svn/trunk@6 77852712-ef1d-11de-8684-7d64432d61a3
This commit is contained in:
parent
9e40cff938
commit
be7f6fd741
28
src/flam3.c
28
src/flam3.c
@ -343,41 +343,34 @@ int flam3_xform_preview(flam3_genome *cp, int xi, double range, int numvals, int
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int flam3_colorhist(flam3_genome *cp, int num_batches, double *hist) {
|
int flam3_colorhist(flam3_genome *cp, int num_batches, randctx *rc, double *hist) {
|
||||||
|
|
||||||
int lp,plp;
|
int lp,plp;
|
||||||
int mycolor;
|
int mycolor;
|
||||||
long int default_isaac_seed = (long int)time(0);
|
long int default_isaac_seed = (long int)time(0);
|
||||||
randctx rc;
|
|
||||||
unsigned short *xform_distrib;
|
unsigned short *xform_distrib;
|
||||||
int sbs = 10000;
|
int sbs = 10000;
|
||||||
double sub_batch[4*10000];
|
double sub_batch[4*10000];
|
||||||
|
|
||||||
/* Set up the isaac rng */
|
|
||||||
for (lp = 0; lp < RANDSIZ; lp++)
|
|
||||||
rc.randrsl[lp] = default_isaac_seed;
|
|
||||||
|
|
||||||
irandinit(&rc,1);
|
|
||||||
|
|
||||||
memset(hist,0,256*sizeof(double));
|
memset(hist,0,256*sizeof(double));
|
||||||
|
|
||||||
|
// get into the attractor
|
||||||
|
if (prepare_precalc_flags(cp))
|
||||||
|
return(1);
|
||||||
|
|
||||||
|
xform_distrib = flam3_create_xform_distrib(cp);
|
||||||
|
|
||||||
for (lp=0;lp<num_batches;lp++) {
|
for (lp=0;lp<num_batches;lp++) {
|
||||||
|
|
||||||
sub_batch[0] = flam3_random_isaac_11(&rc);
|
sub_batch[0] = flam3_random_isaac_11(rc);
|
||||||
sub_batch[1] = flam3_random_isaac_11(&rc);
|
sub_batch[1] = flam3_random_isaac_11(rc);
|
||||||
sub_batch[2] = 0;
|
sub_batch[2] = 0;
|
||||||
sub_batch[3] = 0;
|
sub_batch[3] = 0;
|
||||||
|
|
||||||
// get into the attractor
|
|
||||||
if (prepare_precalc_flags(cp))
|
|
||||||
return(1);
|
|
||||||
|
|
||||||
xform_distrib = flam3_create_xform_distrib(cp);
|
|
||||||
|
|
||||||
if (xform_distrib==NULL)
|
if (xform_distrib==NULL)
|
||||||
return(1);
|
return(1);
|
||||||
flam3_iterate(cp, sbs, 20, sub_batch, xform_distrib, &rc);
|
flam3_iterate(cp, sbs, 20, sub_batch, xform_distrib, rc);
|
||||||
free(xform_distrib);
|
|
||||||
|
|
||||||
// histogram the colors in the sub_batch array
|
// histogram the colors in the sub_batch array
|
||||||
for (plp=0;plp<4*sbs;plp+=4) {
|
for (plp=0;plp<4*sbs;plp+=4) {
|
||||||
@ -389,6 +382,7 @@ int flam3_colorhist(flam3_genome *cp, int num_batches, double *hist) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(xform_distrib);
|
||||||
for (plp=0;plp<256;plp++)
|
for (plp=0;plp<256;plp++)
|
||||||
hist[plp] /= (float)(num_batches*sbs);
|
hist[plp] /= (float)(num_batches*sbs);
|
||||||
|
|
||||||
|
@ -570,7 +570,7 @@ flam3_genome *flam3_parse_from_file(FILE *f, char *fn, int default_flag, int *nc
|
|||||||
void flam3_add_symmetry(flam3_genome *g, int sym);
|
void flam3_add_symmetry(flam3_genome *g, int sym);
|
||||||
|
|
||||||
void flam3_improve_colors(flam3_genome *g, int ntries, int change_palette, int color_resolution);
|
void flam3_improve_colors(flam3_genome *g, int ntries, int change_palette, int color_resolution);
|
||||||
EXPORT int flam3_colorhist(flam3_genome *cp, int num_batches, double *hist);
|
EXPORT int flam3_colorhist(flam3_genome *cp, int num_batches, randctx *rc, double *hist);
|
||||||
EXPORT int flam3_estimate_bounding_box(flam3_genome *g, double eps, int nsamples,
|
EXPORT int flam3_estimate_bounding_box(flam3_genome *g, double eps, int nsamples,
|
||||||
double *bmin, double *bmax, randctx *rc);
|
double *bmin, double *bmax, randctx *rc);
|
||||||
void flam3_rotate(flam3_genome *g, double angle, int interp_type); /* angle in degrees */
|
void flam3_rotate(flam3_genome *g, double angle, int interp_type); /* angle in degrees */
|
||||||
|
Loading…
Reference in New Issue
Block a user