Geo3d_Scalar_Field* ZNeuronTracer::extractSeedOriginal(const Stack *mask) { /* alloc <dist> */ Stack *dist = Stack_Bwdist_L_U16(mask, NULL, 0); /* alloc <seeds> */ Stack *seeds = Stack_Local_Max(dist, NULL, STACK_LOCMAX_CENTER); /* alloc <list> */ Voxel_List *list = Stack_To_Voxel_List(seeds); /* alloc <pa> */ Pixel_Array *pa = Voxel_List_Sampling(dist, list); /* free <dist> */ C_Stack::kill(dist); /* alloc <voxel_array> */ Voxel_P *voxel_array = Voxel_List_To_Array(list, 1, NULL, NULL); //double *pa_array = (double *) pa->array; uint16 *pa_array = (uint16 *) pa->array; printf("%d seeds found.\n", pa->size); /* alloc field */ Geo3d_Scalar_Field *field = Make_Geo3d_Scalar_Field(pa->size); field->size = 0; int i; for (i = 0; i < pa->size; i++) { if (IS_IN_OPEN_RANGE3(voxel_array[i]->x, voxel_array[i]->y, voxel_array[i]->z, 0, seeds->width - 1, 0, seeds->height - 1, 0, seeds->depth - 1)) { field->points[field->size][0] = voxel_array[i]->x; field->points[field->size][1] = voxel_array[i]->y; field->points[field->size][2] = voxel_array[i]->z; field->values[field->size] = sqrt((double)pa_array[i]); field->size++; } } /* free <list> */ Kill_Voxel_List(list); /* free <pa> */ Kill_Pixel_Array(pa); /* free <voxel_array> */ free(voxel_array); /* free <seeds> */ C_Stack::kill(seeds); /* return <field> */ return field; }
int main(int argc, char* argv[]) { Stack *stack = Read_Stack("../data/lobster_neuron_single.tif"); Stack_Not(stack, stack); Stack *dist = Stack_Bwdist(stack); Stack *seeds = Stack_Local_Max(dist, NULL, STACK_LOCMAX_ALTER1); Write_Stack("../data/lobster_neuron_seed.tif", seeds); Voxel_List *list = Stack_To_Voxel_List(seeds); Pixel_Array *pa = Voxel_List_Sampling(dist, list); Pixel_Array_Write("../data/lobster_neuron_seeds.pa", pa); return 0; }