22#include "fmi_image_restore.h"
23#include "fmi_image_filter.h"
24#include "fmi_image_histogram.h"
29 check_image_properties(target,prob);
31 for (i=0;i<prob->volume;i++)
32 if (prob->array[i]>=threshold)
33 target->array[i]=marker;
40 canonize_image(source,prob);
41 canonize_image(source,target);
43 for (i=0;i<prob->volume;i++) {
44 if (prob->array[i ]>= threshold) {
46 target->
original[i] = target->original_undetect;
48 target->array[i]=source->array[i];
56 canonize_image(source,prob);
57 canonize_image(source,target);
59 for (i=0;i<prob->volume;i++)
60 if (prob->array[i]<threshold)
63 target->array[i]=source->array[i];
66static double calculate_original_mean(
FmiImage* source,
int x,
int y,
int hrad,
int vrad)
71 for (h = x - hrad; h <= x + hrad; h++) {
72 for (v = y - vrad; v <= y + vrad; v++) {
73 if (h >= 0 && h < source->width && v >= 0 && v < source->height) {
74 double val = get_pixel_orig(source, h, v, 0);
75 if (val != source->original_undetect) {
83 return (
double)(sum / (double)nhits);
85 return source->original_undetect;
88static void process_original_mean(
FmiImage* source,
FmiImage* target,
int hrad,
int vrad)
91 for (x = 0; x < source->width; x++) {
92 for (y = 0; y < source->height; y++) {
93 put_pixel_orig(target, x, y, 0, calculate_original_mean(source, x, y, hrad, vrad));
103 init_new_image(&median);
104 init_new_image(&original_mean);
106 canonize_image(source,prob);
107 canonize_image(source,target);
108 canonize_image(source,&median);
109 canonize_image(source,&original_mean);
112 for (i=0; i < prob->volume; i++) {
113 if (prob->array[i] >= threshold) {
114 target->array[i] = 0;
115 target->
original[i] = target->original_undetect;
117 target->array[i] = source->array[i];
123 pipeline_process(target, &median, 2, 2, histogram_mean_nonzero);
125 process_original_mean(target, &original_mean, 2, 2);
128 for (i = 0; i < prob->volume; i++){
129 if (prob->array[i] >= threshold) {
130 target->array[i] = median.array[i];
135 reset_image(&median);
136 reset_image(&original_mean);