コード例 #1
0
ファイル: glview.c プロジェクト: penma/dicraft
static void rebinarize() {
	if (image_generated) {
		binary_free(im_slots[0]);
		binary_free(im_slots[1]);
	}

	im_slots[0] = binary_like(im_dicom);
	threshold(im_slots[0], im_dicom, tv);

	im_slots[1] = glvi_binarize(im_dicom, tv);

	image_generated = 1;
}
コード例 #2
0
ファイル: binary_image.c プロジェクト: penma/dicraft
static void py_binary_image_dealloc(py_binary_image *self) {
	if (self->im != NULL) {
		binary_free(self->im);
	}

	Py_TYPE(self)->tp_free((PyObject*)self);
}
コード例 #3
0
/* Free all allocated auth items. */
static void
free_auth_items (void)
{
    addr_list *a;
	
    while ((a = addresses) != NULL)
    {
		addresses = a->next;
		
		binary_free (a->auth.address, a->auth.address_length);
		binary_free (a->auth.number, a->auth.number_length);
		binary_free (a->auth.name, a->auth.name_length);
		binary_free (a->auth.data, a->auth.data_length);
		free (a);
    }
}
コード例 #4
0
ファイル: i3d.c プロジェクト: penma/dicraft
void _i3d_free(struct i3d *im) {
	switch (im->type) {
	case I3D_BINARY:
		binary_free((binary_t)im);
		break;
	case I3D_GRAYSCALE:
		grayscale_free((grayscale_t)im);
		break;
	case I3D_PACKED:
		packed_free((packed_t)im);
		break;
	case I3D_NONE:
		/* wat */
		break;
	}
}
コード例 #5
0
ファイル: examples.c プロジェクト: ClickerMonkey/CDSL
void exampleBinaryTree()
{	
	// Use pooling for efficiency, if you don't want to use pooling
	// then comment out this line.
	pool_binary(32);
	
	BinaryTree* T = newBinaryTree();
	
	//             H
	//       D          L     
	//   B     F     J     N
	// A  C  E  G  I  K  M  O
	// Insert the data into the tree
	binary_add(T, 'H'-'A', "H");
	binary_add(T, 'D'-'A', "D");
	binary_add(T, 'L'-'A', "L");
	binary_add(T, 'B'-'A', "B");
	binary_add(T, 'F'-'A', "F");
	binary_add(T, 'J'-'A', "J");
	binary_add(T, 'N'-'A', "N");
	binary_add(T, 'A'-'A', "A");
	binary_add(T, 'C'-'A', "C");
	binary_add(T, 'E'-'A', "E");
	binary_add(T, 'G'-'A', "G");
	binary_add(T, 'I'-'A', "I");
	binary_add(T, 'K'-'A', "K");
	binary_add(T, 'M'-'A', "M");
	binary_add(T, 'O'-'A', "O");

	binary_display(T, 1, &toString);

	printf("Size: %d\n", T->size);
	printf("Height: %d\n", binary_getHeight(T));

	printf("Traversals:");

	// Display the tree inorder
	printf("\n%16s: ", "In Order");
	binary_traverseInOrder(T, &process);

	printf("\n%16s: ", "Pre Order");
	binary_traversePreOrder(T, &process);

	printf("\n%16s: ", "Post Order");
	binary_traversePostOrder(T, &process);

	printf("\n%16s: ", "Breadth First");
	binary_traverseBreadth(T, &process);

	printf("\n%16s: ", "Depth First");
	binary_traverseDepth(T, &process);

	printf("\n");

	// Remove a node with 2 subtree(s)
	printf("Removing L:\n");
	binary_remove(T, 'L'-'A');
	binary_display(T, 1, &toString);
	printf("New Size: %d\n", T->size);
	// Remove a node with 0 subtree(s) = leaf
	printf("Removing A:\n");
	binary_remove(T, 'A'-'A');
	binary_display(T, 1, &toString);
	printf("New Size: %d\n", T->size);
	// Remove a node with 1 subtree(s) = left
	printf("Removing J:\n");
	binary_remove(T, 'J'-'A');
	binary_display(T, 1, &toString);
	printf("New Size: %d\n", T->size);
	// Remove a node with 1 subtree(s) = right
	printf("Removing B:\n");
	binary_remove(T, 'B'-'A');
	binary_display(T, 1, &toString);
	printf("New Size: %d\n", T->size);
	// Remove a node with 1 subtree(s) = right
	printf("Dropping N:\n");
	binary_drop(T, 'N'-'A');
	binary_display(T, 1, &toString);
	printf("New Size: %d\n", T->size);

	// Remove the bottom level
	printf("Removing bottom level:\n");
	binary_remove(T, 'E'-'A');
	binary_remove(T, 'G'-'A');
	binary_display(T, 1, &toString);
	printf("New Size: %d\n", T->size);
	printf("New Height: %d\n", binary_getHeight(T));

	// Set F to A
	printf("Setting F to E:\n");
	binary_set(T, 'F'-'A', "E");
	binary_display(T, 1, &toString);
	
	binary_clear(T);
	if (T->size == 0)
		printf("Binary Tree Cleared\n");

	// Create another tree with larger strings
	binary_add(T, 3, "Dog");
	binary_add(T, 0, "Ant");
	binary_add(T, 1, "Bat");
	binary_add(T, 2, "Camel");
	binary_add(T, 4, "Eel");
	binary_add(T, 5, "Fish");
	binary_display(T, 5, &toString);

	binary_free(T);
	
	// If you're not using pooling this can be commented out. This will
	// free all pooled nodes from memory. Always call this at the end 
	// of using any List.
	unpool_binary();
}