ROPO
Loading...
Searching...
No Matches
fmi_image_histogram.c
1
22#include <stdio.h>
23#include <math.h> /* sqrt() */
24#include "fmi_util.h"
25#include "fmi_image.h"
26#include "fmi_image_filter.h"
27#include "fmi_image_histogram.h"
28
29FmiImage *histogram_weight_image=NULL;
30int histogram_threshold=0;
31Histogram histogram_weights;
32Histogram histogram_sine;
33Histogram histogram_cosine;
34
35int histogram_sample_count=0;
36int (* histogram_scaling_function)(int param, int value)=NULL;
37int histogram_scaling_parameter=128;
38
39int histogram_semisigmoid(int a,int x){ /* typical histogram_scaling_function */
40 return (255*(x)/(a+x));
41}
42
43int histogram_semisigmoid_inv(int a,int x){ /* typical histogram_scaling_function */
44 return (255-255*(x)/(a+x));
45}
46
47
48
49void clear_histogram_full(Histogram hist){
50 register int i;
51 for (i=0;i<HISTOGRAM_SIZE;i++) hist[i]=0;
52 hist[HIST_MIN]=255;
53}
54
55
56
57/*void set_histogram_sample_count(int width,int height); */
58
59/* WINDOW (or template or mask) - BASED FILTERING */
60
61void convolve(FmiImage *source,FmiImage *target,int mask_width,int mask_height,int **mask,int divisor){
62 register int i,j; /*,k,s,t; */
63
64 fmi_debug(2,"convolve");
65 /* printf("\t hey ,%d) =",divisor); */
66 /*fflush(stdout); */
67 /* printf("\t(%d,%d) =",mask_width,mask_height); */
68 for (j=0;j<mask_height;j++){
69 for (i=0;i<mask_width;i++){
70 printf("\t(%d,%d) =",i,j);
71 fflush(stdout);
72 printf(" %d",mask[j][i]);
73 fflush(stdout);
74 printf("\n");}
75 }
76 /*fmi_debug(2,"convolve"); */
77 if (FMI_DEBUG(2)) write_image("conv",target,PGM_RAW);
78}
79
80
81/* --------------------------------------- */
82
83int histogram_sum(Histogram h){
84 register int i;
85 int sum;
86 sum=0;
87 for (i=0;i<256;i++)
88 sum+=h[i];
89 return sum;
90}
91
92
93int histogram_median_biased(Histogram h,int count){
94 register int i;
95 int sum;
96 sum=0;
97 /* sum2=histogram_sum(h)/2; */
98 for (i=0;i<256;i++){
99 sum+=h[i];
100 if (sum>=count)
101 return i;}
102 return 255;
103}
104
105int histogram_median_biased_top(Histogram h,int count){
106 register int i;
107 int sum;
108 sum=0;
109 for (i=255;i>=0;i--){
110 sum+=h[i];
111 if (sum>=count) return i;}
112 return 0;
113}
114
115/* --------------------------------------- */
116
117int histogram_size(Histogram h){
118 return h[HIST_SIZE];
119}
120
121int histogram_area(Histogram h){
122 return ABS(h[HIST_AREA]);
123}
124
125int histogram_area_inv255(Histogram h){
126 return 255-ABS(h[HIST_AREA]);
127}
128
129int histogram_area2(Histogram h){
130 return pseudo_sigmoid(255,ABS(h[HIST_AREA]));
131}
132
133int histogram_area2_inv255(Histogram h){
134 return 255-pseudo_sigmoid(1,ABS(h[HIST_AREA]));
135}
136
137int histogram_perimeter(Histogram h){
138 return h[HIST_PERIMx3];
139}
140
141int histogram_perimeter2(Histogram h){
142 return pseudo_sigmoid(255,h[HIST_PERIMx3]);
143}
144
145/*
146int histogram_perimeter_normalized(Histogram h){
147return h[HIST_PERIMx3]/3;
148}
149*/
150
151int histogram_compactness(Histogram h){
152 /* (A=�r�, P=2�r maxA=�(P/2�)�=P/4� */
153 /* 255*4� = 3204 "theoretical coeff" */
154 /* * circle aliasing coeff sqrt2 = 4500 */
155 return (4500*ABS(h[HIST_AREA])/(h[HIST_PERIMx3]*h[HIST_PERIMx3]+1));
156}
157
158int histogram_min(Histogram h){
159 return histogram_median_biased(h,1);
160}
161
162int histogram_max(Histogram h){
163 return histogram_median_biased_top(h,1);
164}
165
166int histogram_range(Histogram h){
167 return (histogram_median_biased_top(h,1)-histogram_median_biased(h,1));
168}
169
170
171int histogram_median(Histogram h){ /* computationally heavy */
172 register int i;
173 int sum,count;
174 sum=0;
175 count=histogram_sum(h)/2;
176 for (i=0;i<256;i++){
177 sum+=h[i];
178 if (sum>=count)
179 return i;}
180 return 255;
181}
182
183/*histogram_median2_count=0; */
184void histogram_median2_reset(Histogram h){ /*stupid? */
185 histogram_sample_count=histogram_sum(h);
186}
187
188/* use this instead, precalculate COUNT */
189int histogram_median2(Histogram h){
190 register int i;
191 int sum;
192 sum=0;
193 for (i=0;i<256;i++){
194 sum+=h[i];
195 if (sum>=histogram_sample_count)
196 return i;}
197 return 255;
198}
199
200/* use this instead, precalculate sample COUNT */
201int histogram_median2_top(Histogram h){
202 register int i;
203 int sum;
204 sum=0;
205 for (i=255;i>=0;i--){
206 sum+=h[i];
207 if (sum>=histogram_sample_count)
208 return i;}
209 return 0;
210}
211
212int histogram_mean(Histogram h){
213 register int i;
214 int sum,s;
215 sum=0;
216 s=0;
217 for (i=0;i<256;i++){
218 s+=h[i];
219 sum+=h[i]*i;}
220 return (sum/s);
221}
222
223int histogram_mean_nonzero(Histogram h){
224 register int i;
225 int sum,s;
226 sum=0;
227 s=0;
228 /* i=1,2,... */
229 for (i=1;i<256;i++) {
230 s+=h[i];
231 sum+=h[i]*i;
232 }
233 if (s>0)
234 return (sum/s);
235 else
236 return 0;
237}
238
239int histogram_mean2(Histogram h){
240 register int i;
241 int sum;
242 sum=0;
243 /* s=0; */
244 for (i=0;i<256;i++){
245 /* s+=h[i]; */
246 sum+=h[i]*i;}
247 return (sum/histogram_sample_count);
248}
249
250int histogram_mean_weighted(Histogram h){
251 register int i;
252 int sum,s;
253 sum=0;
254 s=h[HIST_SIZE];
255 if (s<1) s=1;
256 for (i=0;i<256;i++){
257 sum+=h[i]*i;}
258 /* s+=histogram_weights[i]*h[i]; */
259 /*sum+=histogram_weights[i]*h[i]*i;} */
260 return (sum/s);
261}
262
263int (* histogram_mean_weighted_pyramid)(Histogram h) = histogram_mean_weighted;
264
265int histogram_variance_rot(Histogram h){
266 register int i,n;
267 int x,y,sum_x,sum2_x,sum_y,sum2_y;
268 int N;
269 N=1;
270 sum_x = 0;
271 sum2_x = 0;
272 sum_y = 0;
273 sum2_y = 0;
274
275 /* NOTE k=1,... */
276 for (i=1;i<256;i++){
277 n=h[i];
278 N += n;
279 /*w=n; */
280 /*w=(float)n; */
281 /* x=cos(((float)i)*2.0*PI/255.0); */
282 /* y=sin(((float)i)*2.0*PI/255.0); */
283 x=histogram_cosine[i]-128;
284 y=histogram_sine[i]-128;
285 sum_x += n*x;
286 sum2_x += n*x*x;
287 sum_y += n*y;
288 sum2_y += n*y*y;
289 }
290
291 return pseudo_sigmoid (histogram_threshold,(sum2_x-sum_x*sum_x/N + sum2_y-sum_y*sum_y/N)/N/128);
292 /*return pseudo_sigmoid(128.0,255*(sum2_x+sum2_y)); */
293}
294
295/*
296int histogram_weighted_mean(Histogram h,Histogram weights){
297 register int i;
298 int sum,s;
299 sum=0;
300 s=0;
301 for (i=0;i<256;i++){
302 s+=weights[i]*h[i];
303 sum+=weights[i]*h[i]*i;}
304 return (sum/s);
305}
306*/
307
308/*
309int histogram_weighted_mean2(Histogram h){
310 register int i;
311 int sum,s;
312 sum=0;
313 s=0;
314 for (i=0;i<256;i++){
315 s+=histogram_weights[i]*h[i];
316 sum+=histogram_weights[i]*h[i]*i;}
317 return (sum/s);
318}
319*/
320
321int histogram_dom(Histogram h){
322 register int i,i_max;
323 i_max=0;
324 for (i=0;i<256;i++)
325 if (h[i]>h[i_max])
326 i_max=i;
327 return i_max;
328}
329
330int histogram_dom_nonzero(Histogram h){
331 register int i,i_max;
332 i_max=1;
333 for (i=1;i<256;i++)
334 if (h[i]>h[i_max])
335 i_max=i;
336 if (h[i_max]==0)
337 return 0;
338 else
339 return i_max;
340}
341
342int histogram_meanX(Histogram h){
343 if (h[HIST_SIZE]>0)
344 return h[HIST_SUM_I]/h[HIST_SIZE];
345 else
346 return -1;
347}
348
349int histogram_meanY(Histogram h){
350 if (h[HIST_SIZE]>0)
351 return h[HIST_SUM_I]/h[HIST_SIZE];
352 else
353 return -1;
354}
355
356int histogram_principal_component_ratio(Histogram h){
357 /* LONG INT was not enough! */
358 double x,y,xx,xy,yy,n;
359 double Cxx,Cxy,Cyy,SQRT,ans;
360 x= h[HIST_SUM_I];
361 y= h[HIST_SUM_J];
362 xx=h[HIST_SUM_II];
363 xy=h[HIST_SUM_IJ];
364 yy=h[HIST_SUM_JJ];
365 /* A=h[HIST_AREA]; */
366 /* n=h[HIST_PERIMx3]; */
367 n=h[HIST_SIZE];
368
369 /* histogram_dump_stats(h); return 127; */
370
371 if (n==0) return 255;
372 Cxx=(xx-x*x/n)/n;
373 Cyy=(yy-y*y/n)/n;
374 Cxy=(xy-x*y/n)/n;
375 /*
376 Cxy=(h[HIST_SUM_IJ]-h[HIST_SUM_I]*h[SUM_Y]/A)/A;
377 Cyy=(h[SUM_YY]-h[SUM_Y]*h[SUM_Y]/A)/A;
378 */
379 /* SQR=((Cxx+Cyy)*(Cxx+Cyy)-4*(Cxx*Cyy-Cxy*Cxy)); */
380 SQRT=sqrt((Cxx-Cyy)*(Cxx-Cyy)+4*Cxy*Cxy);
381 /* SQRT=sqrt((double)((Cxx+Cyy)*(Cxx+Cyy)-4*(Cxx*Cyy-Cxy*Cxy))) */
382 /* SQRT=sqrt((double)SQR); */
383 ans=255.0*(Cxx+Cyy-SQRT)/(Cxx+Cyy+SQRT);
384 /*ans=sqrt(Cxx/(Cyy)); */
385 if ((Cxx+Cyy)==0)
386 return 255;
387 else
388 return /*255*sqrt((Cxx+Cyy-SQRT)/(Cxx+Cyy+SQRT)); */
389 ans;
390 /*return 16*d/(a+1); */
391 /*return 255*D; */
392}
393
394int histogram_smoothness(Histogram h){
395 int temp,temp2;
396 temp=histogram_compactness(h);
397 temp2=histogram_principal_component_ratio(h);
398 if (temp>255) temp=255;
399 if (temp2<1) temp2=1;
400 return sqrt(255*temp*temp/temp2);
401}
402
403/* HISTOGRAM WINDOW - BASED FILTERING */
404/* ==================================================================== */
405
406
407void histogram_dump_nonzero(Histogram h){
408 register int i;
409 /* int sum,s; */
410 /*sum=0; */
411 /*s=0; */
412 /* for (i=0;i<HISTOGRAM_SIZE;i++) */
413 for (i=0;i<HISTOGRAM_SIZE;i++)
414 if (h[i]!=0)
415 fprintf(stderr,"histogram[%d]=%d\n",i,(int)h[i]);
416}
417
418
419void histogram_dump(Histogram h){
420 register int i;
421 int sum,s;
422 sum=0;
423 s=0;
424 for (i=0;i<256;i++){
425 /* fprintf(stderr," %d \t %d\t",i,h[i]); */
426 s+=h[i];
427 sum+=h[i]*i;}
428 fprintf(stderr,"\n sum=%d \t hits=%d \t mean=%d \n",sum,s,sum/s);
429}
430
431void histogram_dump_stats(Histogram h){
432 char *format="%d\t%d %s\n";
433 printf(format,h[HIST_SIZE],HIST_SIZE,"HIST_SIZE");
434 printf(format,h[HIST_SUM],HIST_SUM,"HIST_SUM");
435 printf(format,h[HIST_MIN],HIST_MIN,"HIST_MIN");
436 printf(format,h[HIST_AREA],HIST_AREA,"HIST_AREA");
437 printf(format,h[HIST_MAX],HIST_MAX,"HIST_MAX");
438 printf(format,h[HIST_PERIMx3],HIST_PERIMx3,"HIST_PERIMx3");
439 printf(format,h[HIST_SUM_I],HIST_SUM_I,"HIST_SUM_I");
440 printf(format,h[HIST_SUM_J],HIST_SUM_J,"HIST_SUM_J");
441 printf(format,h[HIST_SUM_II],HIST_SUM_II,"HIST_SUM_II");
442 printf(format,h[HIST_SUM_JJ],HIST_SUM_JJ,"HIST_SUM_JJ");
443 printf(format,h[HIST_SUM_IJ],HIST_SUM_IJ,"HIST_SUM_IJ");
444 printf(format,h[HIST_MIN_I],HIST_MIN_I,"HIST_MIN_I");
445 printf(format,h[HIST_MIN_J],HIST_MIN_J,"HIST_MIN_J");
446 printf(format,h[HIST_MAX_I],HIST_MAX_I,"HIST_MAX_I");
447 printf(format,h[HIST_MAX_J],HIST_MAX_J,"HIST_MAX_J");
448}
449
450
451void initialize_histogram(FmiImage *source,Histogram histogram,int hrad,int vrad,int i,int j,int (* hist_func)(Histogram)){
452 int k,m,n,w;
453 float alpha;
454
455 clear_histogram(histogram); /*full? */
456
457 /* EXCLUSIVE INITS */
458 if (hist_func==histogram_mean_weighted) {
459 fmi_debug(2,"initialize_histogram: histogram_mean_weighted, source:");
460 image_info(source);
461 fmi_debug(2,"initialize_histogram: histogram_mean_weighted, weight:");
462 /* canonize_images(source,histogram_weight_image); */
463 image_info(histogram_weight_image);
464 histogram[HIST_SIZE]=0;
465 for (k=0;k<source->channels;k++) {
466 for (m=-hrad;m<=hrad;m++) {
467 for (n=-vrad;n<=vrad;n++) {
468 w=get_pixel(histogram_weight_image,i+m,j+n,k);
469 histogram[get_pixel(source,i+m,j+n,k)]+=w;
470 histogram[HIST_SIZE]+=w;
471 }
472 }
473 }
474 }
475 else {
476 for (k=0; k < source->channels; k++) {
477 for (m=-hrad; m <= hrad; m++) {
478 for (n=-vrad; n <= vrad; n++) {
479 ++histogram[get_pixel(source,i+m,j+n,k)];
480 }
481 }
482 }
483 }
484
485 /* quick add - check if ok? */
486 if (histogram_sample_count==0)
487 histogram_sample_count=(2*hrad+1)*(2*vrad+1)/2;
488
489 /* ADDED INITS */
490 if (hist_func==histogram_variance_rot)
491 for (i=0;i<256;i++) {
492 alpha=((float)i)/255*2.0*PI;
493 histogram_cosine[i]=128+127*cos(alpha);
494 histogram_sine[i] =128+127*sin(alpha);
495 }
496 fmi_debug(2,"initialize_histogram");
497}
498
499
500/*
501void initialize_histogram_trigon(){
502 int i;
503 float alpha;
504 for (i=0;i<256;i++){
505 alpha=((float)i)/255*2.0*PI;
506 histogram_cosine[i]=128+127*cos(alpha);
507 histogram_sine[i] =128+127*sin(alpha);
508 }
509}
510*/
511
512void (* histogram_window_up)(FmiImage *,Histogram,int,int,int *,int *);
513void (* histogram_window_down)(FmiImage *,Histogram,int,int,int *,int *);
514void (* histogram_window_right)(FmiImage *,Histogram,int,int,int *,int *);
515void (* histogram_window_left)(FmiImage *,Histogram,int,int,int *,int *);
516/*left(FmiImage *source,Histogram histogram,int hrad,int vrad,int *i,int *j) */
517
518
519void up(FmiImage *source,Histogram histogram,int hrad,int vrad,int *i,int *j){
520 register int m,k;
521 k=0;
522 for (m=-hrad;m<=hrad;m++){
523 --histogram[get_pixel(source,(*i)+m,(*j)-vrad ,k)];
524 ++histogram[get_pixel(source,(*i)+m,(*j)+vrad+1,k)];}
525 (*j)++;
526}
527void down(FmiImage *source,Histogram histogram,int hrad,int vrad,int *i,int *j){
528 register int m,k;
529 k=0;
530 for (m=-hrad;m<=hrad;m++){
531 --histogram[get_pixel(source,(*i)+m,(*j)+vrad ,k)];
532 ++histogram[get_pixel(source,(*i)+m,(*j)-vrad-1,k)];}
533 (*j)--;
534}
535
536void right(FmiImage *source,Histogram histogram,int hrad,int vrad,int *i,int *j){
537 register int n,k;
538 k=0;
539 for (n=-vrad;n<=vrad;n++){
540 --histogram[get_pixel(source,*i-hrad ,*j+n,k)];
541 ++histogram[get_pixel(source,*i+hrad+1,*j+n,k)];}
542 (*i)++;
543}
544
545void left(FmiImage *source,Histogram histogram,int hrad,int vrad,int *i,int *j){
546 register int n,k;
547 /* const int height=vrad*2+1; */
548 k=0;
549 /* for (k=0;k<source->channels;k++) */
550 for (n=-vrad;n<=vrad;n++){
551 --histogram[get_pixel(source,*i+hrad ,*j+n,k)];
552 ++histogram[get_pixel(source,*i-hrad-1,*j+n,k)];}
553 (*i)--;
554}
555
556
557
558void up_w(FmiImage *source,Histogram histogram,int hrad,int vrad,int *i,int *j){
559 register int m,w;
560 register int ii;
561 register int jo=*j-vrad;
562 register int jn=*j+vrad+1;
563 for (m=-hrad;m<=hrad;m++){
564 ii=*i+m;
565 w=get_pixel(histogram_weight_image,ii,jo,0);
566 histogram[get_pixel(source,ii,jo,0)] -= w;
567 histogram[HIST_SIZE] -= w;
568 w=get_pixel(histogram_weight_image,ii,jn,0);
569 histogram[get_pixel(source,ii,jn,0)] += w;
570 histogram[HIST_SIZE] += w;
571 }
572 (*j)++;
573}
574void down_w(FmiImage *source,Histogram histogram,int hrad,int vrad,int *i,int *j){
575 register int m,w;
576 register int ii;
577 register int jo=*j+vrad;
578 register int jn=*j-vrad-1;
579 /* k=0; */
580 for (m=-hrad;m<=hrad;m++){
581 ii=*i+m;
582 w=get_pixel(histogram_weight_image,ii,jo,0);
583 histogram[get_pixel(source,ii,jo,0)] -= w;
584 histogram[HIST_SIZE] -= w;
585 w=get_pixel(histogram_weight_image,ii,jn,0);
586 histogram[get_pixel(source,ii,jn,0)] += w;
587 histogram[HIST_SIZE] += w;
588 }
589 (*j)--;
590}
591
592void right_w(FmiImage *source,Histogram histogram,int hrad,int vrad,int *i,int *j){
593 register int n,w;
594 register int jj;
595 register int io=*i-hrad;
596 register int in=*i+hrad+1;
597 for (n=-vrad;n<=vrad;n++){
598 jj=*j+n;
599 w=get_pixel(histogram_weight_image,io,jj,0);
600 histogram[get_pixel(source,io,jj,0)] -= w;
601 histogram[HIST_SIZE] -= w;
602 w=get_pixel(histogram_weight_image,in,jj,0);
603 histogram[get_pixel(source,in,jj,0)] += w;
604 histogram[HIST_SIZE] += w;
605 }
606 (*i)++;
607}
608
609void left_w(FmiImage *source,Histogram histogram,int hrad,int vrad,int *i,int *j){
610 register int n,w;
611 register int jj;
612 register int io=*i+hrad;
613 register int in=*i-hrad-1;
614 for (n=-vrad;n<=vrad;n++){
615 jj=*j+n;
616 w = get_pixel(histogram_weight_image,io,jj,0);
617 histogram[w * get_pixel(source,io,jj,0)] -= w;
618 histogram[HIST_SIZE] -= w;
619 w = get_pixel(histogram_weight_image,in,jj,0);
620 histogram[get_pixel(source,in,jj,0)] += w;
621 histogram[HIST_SIZE] += w;
622 }
623 (*i)--;
624}
625
626void pipeline_process_col_major(FmiImage *source,FmiImage *target,int hrad,int vrad,int (* histogram_function)(Histogram),Histogram histogram){
627 int i,j,k;
628 i=j=k=0;
629
630 fmi_debug(4,"pipeline_process_col_major");
631 /* MAIN LOOP */
632 while (1){
633
634 /* UP */
635 while (j<source->height-1){
636 /* if (0){ fprintf(stderr," - sum=i%d\t j=%d\n",i,j);} */
637 histogram_window_up(source,histogram,hrad,vrad,&i,&j);
638 put_pixel(target,i,j,k,histogram_function(histogram));
639 if (0){ fprintf(stderr," - sum=i%d\t j=%d\n",i,j);}
640 /*dump_histogram(histogram); */
641 }
642
643 /* ONE STEP RIGHT */
644 if (i<source->width-1){
645 histogram_window_right(source,histogram,hrad,vrad,&i,&j);
646 put_pixel(target,i,j,k,histogram_function(histogram));}
647 else
648 return;
649
650 /* DOWN */
651 while (j>0){
652 histogram_window_down(source,histogram,hrad,vrad,&i,&j);
653 put_pixel(target,i,j,k,histogram_function(histogram));
654 }
655
656 /* ONE STEP RIGHT */
657 if (i<source->width-1){
658 histogram_window_right(source,histogram,hrad,vrad,&i,&j);
659 put_pixel(target,i,j,k,histogram_function(histogram));
660 }
661 else
662 return;
663 }
664}
665
666void pipeline_process_row_major(FmiImage *source,FmiImage *target,int hrad,int vrad,int (* histogram_function)(Histogram),Histogram histogram){
667 int i,j,k;
668 i=j=k=0;
669 fmi_debug(4,"pipeline_process_row_major");
670
671 /* MAIN LOOP */
672 while (1){
673
674 /* RIGHT */
675 while (i<source->width-1){
676 histogram_window_right(source,histogram,hrad,vrad,&i,&j);
677 put_pixel(target,i,j,k,histogram_function(histogram));
678 }
679
680 /* ONE STEP UP */
681 if (j<source->height-1){
682 histogram_window_up(source,histogram,hrad,vrad,&i,&j);
683 put_pixel(target,i,j,k,histogram_function(histogram));}
684 else
685 return;
686
687 /* LEFT */
688 while (i>0){
689 histogram_window_left(source,histogram,hrad,vrad,&i,&j);
690 put_pixel(target,i,j,k,histogram_function(histogram));
691 }
692
693 /* ONE STEP UP */
694 if (j<source->height-1){
695 histogram_window_up(source,histogram,hrad,vrad,&i,&j);
696 put_pixel(target,i,j,k,histogram_function(histogram));}
697 else
698 return;
699 }
700}
701
702
703void pipeline_process(FmiImage *source,FmiImage *target,int hrad,int vrad,int (* histogram_function)(Histogram)){
704 /*int i,j; */
705 /* register int k,m,n; */
706 /* FmiImage *target_ptr; */
707 Histogram histogram;
708 int width, height; /*,count; */
709
710 /* INITIALIZE */
711 width=hrad*2+1;
712 height=vrad*2+1;
713 /* histogram_median2_count=(width*height+1)/2; */
714
715 /*
716 if (histogram_function==histogram_mean_weighted_pyramid){
717 fmi_debug(1,"pipeline_process: pyramid");
718 for (i=0;i<128;i++) histogram_weights[i]=i+1;
719 for (i=0;i<128;i++) histogram_weights[128+i]=128-i;
720 }
721 */
722
723 histogram_window_up = up;
724 histogram_window_down = down;
725 histogram_window_right = right;
726 histogram_window_left = left;
727
728 if (histogram_function==histogram_mean_weighted){
729 fmi_debug(2,"pipeline_process: histogram_mean_weighted");
730 if (histogram_weight_image==NULL)
731 fmi_error("pipeline_process: histogram_weight_image==NULL");
732 histogram_window_up = up_w;
733 histogram_window_down = down_w;
734 histogram_window_right = right_w;
735 histogram_window_left = left_w;
736 }
737
738 fmi_debug(4,"pipeline_process");
739 if (FMI_DEBUG(4))
740 printf(" width=%d\t height=%d\n",width,height);
741
742 /* INITIALIZE */
743 initialize_histogram(source,histogram,hrad,vrad,0,0,histogram_function);
744 /* dump_histogram(histogram); */
745
746 /* i=j=k=0; */
747 put_pixel(target,0,0,0,histogram_function(histogram));
748
749 if (histogram_function==histogram_mean_weighted){
750 fmi_debug(2,"pipeline_process: histogram_mean_weighted");
751 }
752
753 if (width > height) {
754 pipeline_process_row_major(source, target, hrad, vrad, histogram_function, histogram);
755 } else {
756 pipeline_process_col_major(source, target, hrad, vrad, histogram_function, histogram);
757 }
758}