aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChristian C <cc@localhost>2025-04-01 17:38:32 -0700
committerChristian C <cc@localhost>2025-04-01 17:38:32 -0700
commita18cea2fef7aa1545c9a984b60919541b26a6f84 (patch)
treed1ab991e28b701bdfdc9035704389ad6c57391c9 /include
parent2bc54ac42b831a7dfcba26c2d12ba002f80a5e40 (diff)
Clang Format
Diffstat (limited to 'include')
-rw-r--r--include/lib/algo/avl_tree.h26
-rw-r--r--include/lib/algo/flood_fill.h7
-rw-r--r--include/lib/color.h11
-rw-r--r--include/lib/data/image_types.h14
-rw-r--r--include/lib/dir.h10
-rw-r--r--include/lib/file.h2
-rw-r--r--include/lib/monad.h2
-rw-r--r--include/lib/png.h4
-rw-r--r--include/lib/seg/mask_data.h33
-rw-r--r--include/lib/seg/util.h20
-rw-r--r--include/lib/time.h4
-rw-r--r--include/test/__meta__.h18
-rw-r--r--include/test/lib/color.h9
-rw-r--r--include/test/lib/dir.h9
-rw-r--r--include/test/lib/time.h6
15 files changed, 98 insertions, 77 deletions
diff --git a/include/lib/algo/avl_tree.h b/include/lib/algo/avl_tree.h
index 0221952..18cf34b 100644
--- a/include/lib/algo/avl_tree.h
+++ b/include/lib/algo/avl_tree.h
@@ -9,44 +9,44 @@
#define AvlHeight_t uint8_t
-typedef bool_t (*AvlComparator)(void*, void*);
+typedef bool_t (*AvlComparator)(void *, void *);
typedef struct AVLNode {
- void* data;
+ void *data;
AvlComparator compare;
- struct AVLNode* left;
- struct AVLNode* right;
+ struct AVLNode *left;
+ struct AVLNode *right;
AvlHeight_t height;
} AVLNode;
// Get the height of an AVL node
-AvlHeight_t get_height(AVLNode* node);
+AvlHeight_t get_height(AVLNode *node);
// Get the Maximum Height between two
AvlHeight_t max_height(AvlHeight_t a, AvlHeight_t b);
// Get the balance factor of a node
-ssize_t get_balance_factor(AVLNode* node);
+ssize_t get_balance_factor(AVLNode *node);
// Rotate an AVL node right
-AVLNode* right_rotate(AVLNode* parent);
+AVLNode *right_rotate(AVLNode *parent);
// Rotate an AVL node left
-AVLNode* left_rotate(AVLNode* parent);
+AVLNode *left_rotate(AVLNode *parent);
// Create AVL node
-AVLNode* create_avl_node(void* data, AvlComparator compare);
+AVLNode *create_avl_node(void *data, AvlComparator compare);
// Insert data into AVL tree
-Result avl_insert(AVLNode* node, void* data, AvlComparator compare);
+Result avl_insert(AVLNode *node, void *data, AvlComparator compare);
// In-order traversal print pointer
-void print_in_order(AVLNode* root);
+void print_in_order(AVLNode *root);
// Free avl tree nodes starting at root
-void free_avl_tree(AVLNode* root);
+void free_avl_tree(AVLNode *root);
// Free avl tree and their data starting at root
-void free_avl_tree_nodes(AVLNode* root);
+void free_avl_tree_nodes(AVLNode *root);
#endif
diff --git a/include/lib/algo/flood_fill.h b/include/lib/algo/flood_fill.h
index f446e3b..3bacaf9 100644
--- a/include/lib/algo/flood_fill.h
+++ b/include/lib/algo/flood_fill.h
@@ -12,9 +12,12 @@
// 1. Check that the (x,y) is within the picture
// 2. Check if the (x,y) coordinate in the mask is unused
// 3. Check if the (x,y) coordinate in the image is non-background
-// 4. Check if the (x,y) coordinate in the image is the same color as the fill color
+// 4. Check if the (x,y) coordinate in the image is the same color as the fill
+// color
// 5. If all hold, set the label for the pixel, and check each neighbor
// Otherwise, stop flooding
-bool_t flood(ImageData_t* image, MaskData_t* mask, size_t width, size_t height, size_t channels, size_t x, size_t y, ImageData_t* fill_color, MaskData_t label);
+bool_t flood(ImageData_t *image, MaskData_t *mask, size_t width, size_t height,
+ size_t channels, size_t x, size_t y, ImageData_t *fill_color,
+ MaskData_t label);
#endif
diff --git a/include/lib/color.h b/include/lib/color.h
index ceaecbd..f462a05 100644
--- a/include/lib/color.h
+++ b/include/lib/color.h
@@ -1,20 +1,21 @@
#ifndef INC_LIB_COLOR_H
#define INC_LIB_COLOR_H
-#include <stdint.h>
-#include <stddef.h>
#include <lib/bool.h>
#include <lib/data/image_types.h>
+#include <stddef.h>
+#include <stdint.h>
// Color Equal to Background
// Background: zeros in RGB, alpha can be whatever
-bool_t color_zero(const ImageData_t* color1, size_t channels);
+bool_t color_zero(const ImageData_t *color1, size_t channels);
// Color Equality
// Determine if two colors are identical
-bool_t color_equal(const ImageData_t* color1, const ImageData_t* color2, size_t channels);
+bool_t color_equal(const ImageData_t *color1, const ImageData_t *color2,
+ size_t channels);
// Print out the `channels` length color vector
-void print_color(ImageData_t* color, size_t channels);
+void print_color(ImageData_t *color, size_t channels);
#endif
diff --git a/include/lib/data/image_types.h b/include/lib/data/image_types.h
index 8df5feb..af533ce 100644
--- a/include/lib/data/image_types.h
+++ b/include/lib/data/image_types.h
@@ -1,13 +1,13 @@
#ifndef INC_LIB_DATA_IMAGE_TYPES_H
#define INC_LIB_DATA_IMAGE_TYPES_H
-#include <stdint.h>
#include <stddef.h>
+#include <stdint.h>
#define ImageData_t uint8_t
-#define Image_t ImageData_t***
+#define Image_t ImageData_t ***
#define MaskData_t uint16_t
-#define Mask_t MaskData_t**
+#define Mask_t MaskData_t **
typedef struct Image {
size_t width;
@@ -22,10 +22,10 @@ typedef struct Mask {
Mask_t image;
} Mask;
-Image* create_image(size_t width, size_t height, size_t depth);
-Mask* create_image_mask(size_t width, size_t height);
+Image *create_image(size_t width, size_t height, size_t depth);
+Mask *create_image_mask(size_t width, size_t height);
-void free_image(Image* image);
-void free_image_mask(Mask* image_mask);
+void free_image(Image *image);
+void free_image_mask(Mask *image_mask);
#endif
diff --git a/include/lib/dir.h b/include/lib/dir.h
index 0ec9cac..81f37f3 100644
--- a/include/lib/dir.h
+++ b/include/lib/dir.h
@@ -1,19 +1,19 @@
#ifndef INC_LIB_DIR_H
#define INC_LIB_DIR_H
-#include <lib/lib.h>
#include <lib/bool.h>
+#include <lib/lib.h>
// Is directory
-bool_t is_directory(char* dirname);
+bool_t is_directory(char *dirname);
// List directory
-char** list_directory(char* dirname);
+char **list_directory(char *dirname);
// Get full path
-char* full_path(char* dir, char* file);
+char *full_path(char *dir, char *file);
// Determines if file name has tif file extension
-bool_t is_tif_ext(char* file_name);
+bool_t is_tif_ext(char *file_name);
#endif
diff --git a/include/lib/file.h b/include/lib/file.h
index 9a231cc..395c1f8 100644
--- a/include/lib/file.h
+++ b/include/lib/file.h
@@ -5,6 +5,6 @@
#include <stddef.h>
// Write array to a file
-bool_t write_array(char* output_file_name, void* array, size_t size);
+bool_t write_array(char *output_file_name, void *array, size_t size);
#endif
diff --git a/include/lib/monad.h b/include/lib/monad.h
index af5eb3a..21cbe61 100644
--- a/include/lib/monad.h
+++ b/include/lib/monad.h
@@ -4,7 +4,7 @@
#include <lib/bool.h>
typedef struct Result {
- void* data;
+ void *data;
bool_t success;
} Result;
diff --git a/include/lib/png.h b/include/lib/png.h
index c21fede..ca1179b 100644
--- a/include/lib/png.h
+++ b/include/lib/png.h
@@ -15,12 +15,12 @@ typedef struct pixel_t {
} Pixel;
typedef struct bitmap_t {
- Pixel* image_buffer;
+ Pixel *image_buffer;
size_t width;
size_t height;
} Bitmap;
// Save bitmap to file
-void save_png(Bitmap* bitmap, char* fname);
+void save_png(Bitmap *bitmap, char *fname);
#endif
diff --git a/include/lib/seg/mask_data.h b/include/lib/seg/mask_data.h
index 70bacfa..02276f0 100644
--- a/include/lib/seg/mask_data.h
+++ b/include/lib/seg/mask_data.h
@@ -12,55 +12,56 @@ typedef struct MaskData {
} MaskData;
// Allocate Mask Data for Label
-MaskData* create_mask_data(MaskData_t label);
+MaskData *create_mask_data(MaskData_t label);
// Compare mask data labels
-bool_t compare_labels(MaskData* left, MaskData* right);
+bool_t compare_labels(MaskData *left, MaskData *right);
// Create AVL Mask node
-AVLNode* create_avl_mask_node(MaskData* data);
+AVLNode *create_avl_mask_node(MaskData *data);
// Insert MaskData into the AVL Tree
-Result insert_mask(AVLNode* node, MaskData* data);
+Result insert_mask(AVLNode *node, MaskData *data);
// Allocate a label's Mask data in a tree
// If it already exists, skip the allocation
-AVLNode* insert_mask_alloc(AVLNode* node, MaskData_t label);
+AVLNode *insert_mask_alloc(AVLNode *node, MaskData_t label);
// Print AVL Node Mask Data Label
-void print_label(AVLNode* root);
+void print_label(AVLNode *root);
// Increase the label's area
-bool_t increase_label_area(AVLNode* root, MaskData_t label);
+bool_t increase_label_area(AVLNode *root, MaskData_t label);
// Increase the label's perimeter
-bool_t increase_label_perimeter(AVLNode* root, MaskData_t label);
+bool_t increase_label_perimeter(AVLNode *root, MaskData_t label);
// Increase the label's area
// Create an AVL node if it doesn't exist
-AVLNode* increase_label_area_alloc(AVLNode* root, MaskData_t label);
+AVLNode *increase_label_area_alloc(AVLNode *root, MaskData_t label);
// Increase the label's perimeter
// Create an AVL node if it doesn't exist
-AVLNode* increase_label_perimeter_alloc(AVLNode* root, MaskData_t label);
+AVLNode *increase_label_perimeter_alloc(AVLNode *root, MaskData_t label);
// Comparison of MaskData_ts
-bool_t compare_image_mask_data_t(MaskData_t* s1, MaskData_t* s2);
+bool_t compare_image_mask_data_t(MaskData_t *s1, MaskData_t *s2);
// In-order traversal print pointer
-void print_in_order_image_mask_data_t(AVLNode* root);
+void print_in_order_image_mask_data_t(AVLNode *root);
// Check if MaskData_t in AVLTree with MaskData_t* data
-bool_t in_image_mask_data_t_tree(AVLNode* root, MaskData_t value);
+bool_t in_image_mask_data_t_tree(AVLNode *root, MaskData_t value);
// Filter out small masks
// Assumption: Contiguous labeling
-AVLNode* get_small_labels(AVLNode* removal_tree, AVLNode* label_tree, size_t min_area, size_t min_perimeter);
+AVLNode *get_small_labels(AVLNode *removal_tree, AVLNode *label_tree,
+ size_t min_area, size_t min_perimeter);
// Get mask label data
-AVLNode* get_mask_data(Mask* mask);
+AVLNode *get_mask_data(Mask *mask);
// Filter out small masks in mask
-void filter_small_masks(Mask* mask, size_t min_area, size_t min_perimeter);
+void filter_small_masks(Mask *mask, size_t min_area, size_t min_perimeter);
#endif
diff --git a/include/lib/seg/util.h b/include/lib/seg/util.h
index 9f66670..d726be8 100644
--- a/include/lib/seg/util.h
+++ b/include/lib/seg/util.h
@@ -2,40 +2,40 @@
#define INC_LIB_SEG_UTIL_H
#include <lib/bool.h>
-#include <lib/png.h>
#include <lib/data/image_types.h>
-#include <stdint.h>
+#include <lib/png.h>
#include <stddef.h>
+#include <stdint.h>
// Determine if coordinate is on a mask boundary
// Assumes mask is (WxH)
-bool_t is_on_mask_boundary(Mask* mask, size_t x, size_t y);
+bool_t is_on_mask_boundary(Mask *mask, size_t x, size_t y);
// Dilate masks by one 4-connected pixel
-void dilate(Mask* mask);
+void dilate(Mask *mask);
// Erode masks by one 4-connected pixel
-void erode(Mask* mask);
+void erode(Mask *mask);
// Close up masks by N-pixels
-void closeup(Mask* mask, size_t count);
+void closeup(Mask *mask, size_t count);
// Combine Label Masks
// For all empty spaces in the destination, put the extra label if it exists
// Allocates an array if destination is unallocated
-Mask* combine_masks(Mask *destination, Mask *extra_labels);
+Mask *combine_masks(Mask *destination, Mask *extra_labels);
// Process Tif File to Labels
// width, height will be overwritten with image dimensions
// starting_label_p will be incremented for each label found in the image
-Mask* tif_to_labels(char* tif_file_name, MaskData_t *starting_label_p);
+Mask *tif_to_labels(char *tif_file_name, MaskData_t *starting_label_p);
// Convert mask to bitmap
-Bitmap* image_mask_data_to_bitmap(const Mask* mask);
+Bitmap *image_mask_data_to_bitmap(const Mask *mask);
// Reduce a mask to the contiguous regions
// Automatically update pointer to contiguous mask
// Freeing previous mask
-void reduce_contiguous_regions(Mask* mask, MaskData_t* total_labels);
+void reduce_contiguous_regions(Mask *mask, MaskData_t *total_labels);
#endif
diff --git a/include/lib/time.h b/include/lib/time.h
index 1adf428..809a8a0 100644
--- a/include/lib/time.h
+++ b/include/lib/time.h
@@ -3,7 +3,9 @@
#include <time.h>
-#define TIME(var) struct timespec var;get_time(&var)
+#define TIME(var) \
+ struct timespec var; \
+ get_time(&var)
// Difference in Time
// Compute the difference between timespec structs
diff --git a/include/test/__meta__.h b/include/test/__meta__.h
index 17e0b99..f0c10b4 100644
--- a/include/test/__meta__.h
+++ b/include/test/__meta__.h
@@ -2,21 +2,29 @@
#define INC_TEST___META___H
#include <lib/bool.h>
-#include <stdio.h>
#include <stddef.h>
+#include <stdio.h>
#define TestCount_t uint16_t
#ifdef TEST_SHOW_PASS
-#define _TEST_PASS(s,sub,n) fprintf(stderr, "(%4X) \x1b[92mPASS\x1b[0m %s/%s\n", ++n, s, sub)
+#define _TEST_PASS(s, sub, n) \
+ fprintf(stderr, "(%4X) \x1b[92mPASS\x1b[0m %s/%s\n", ++n, s, sub)
#else
-#define _TEST_PASS(s,sub,n) ++n
+#define _TEST_PASS(s, sub, n) ++n
#endif
-#define _TEST_FAIL(s,sub,n) fprintf(stderr, "(%4X) \x1b[91mFAIL\x1b[0m %s/%s\n", ++n, s, sub)
+#define _TEST_FAIL(s, sub, n) \
+ fprintf(stderr, "(%4X) \x1b[91mFAIL\x1b[0m %s/%s\n", ++n, s, sub)
#ifndef _TEST_RESULT
-#define _TEST_RESULT(main_string,subtest_string,result,n,n_success) if (!result) {_TEST_FAIL(main_string,subtest_string, n);} else {_TEST_PASS(main_string,subtest_string,n);n_success++;}
+#define _TEST_RESULT(main_string, subtest_string, result, n, n_success) \
+ if (!result) { \
+ _TEST_FAIL(main_string, subtest_string, n); \
+ } else { \
+ _TEST_PASS(main_string, subtest_string, n); \
+ n_success++; \
+ }
#endif
#endif
diff --git a/include/test/lib/color.h b/include/test/lib/color.h
index 2e9b863..e1598cb 100644
--- a/include/test/lib/color.h
+++ b/include/test/lib/color.h
@@ -3,14 +3,17 @@
#include <test/__meta__.h>
#ifndef TEST_RESULT
-#define TEST_RESULT(subtest,result,n,n_success) _TEST_RESULT("LIB/COLOR",subtest,result,n,n_success)
+#define TEST_RESULT(subtest, result, n, n_success) \
+ _TEST_RESULT("LIB/COLOR", subtest, result, n, n_success)
#endif
#include <lib/color.h>
#include <lib/data/image_types.h>
-bool_t test_color_zero(const ImageData_t* color1, size_t channels, bool_t result);
-bool_t test_color_equal(const ImageData_t* color1, const ImageData_t* color2, size_t channels, bool_t result);
+bool_t test_color_zero(const ImageData_t *color1, size_t channels,
+ bool_t result);
+bool_t test_color_equal(const ImageData_t *color1, const ImageData_t *color2,
+ size_t channels, bool_t result);
// Meta test function
bool_t TEST_lib_color();
diff --git a/include/test/lib/dir.h b/include/test/lib/dir.h
index 64482df..6d46267 100644
--- a/include/test/lib/dir.h
+++ b/include/test/lib/dir.h
@@ -3,14 +3,15 @@
#include <test/__meta__.h>
#ifndef TEST_RESULT
-#define TEST_RESULT(subtest,result,n,n_success) _TEST_RESULT("LIB/DIR",subtest,result,n,n_success)
+#define TEST_RESULT(subtest, result, n, n_success) \
+ _TEST_RESULT("LIB/DIR", subtest, result, n, n_success)
#endif
#include <lib/dir.h>
-bool_t test_is_directory(char* dirname, bool_t result);
-bool_t test_full_path(char* dirname, char* file, char* result);
-bool_t test_is_tif_ext(char* file_name, bool_t result);
+bool_t test_is_directory(char *dirname, bool_t result);
+bool_t test_full_path(char *dirname, char *file, char *result);
+bool_t test_is_tif_ext(char *file_name, bool_t result);
// Meta test function
bool_t TEST_lib_dir();
diff --git a/include/test/lib/time.h b/include/test/lib/time.h
index cdf464e..d242c65 100644
--- a/include/test/lib/time.h
+++ b/include/test/lib/time.h
@@ -3,12 +3,14 @@
#include <test/__meta__.h>
#ifndef TEST_RESULT
-#define TEST_RESULT(subtest,result,n,n_success) _TEST_RESULT("LIB/TIME",subtest,result,n,n_success)
+#define TEST_RESULT(subtest, result, n, n_success) \
+ _TEST_RESULT("LIB/TIME", subtest, result, n, n_success)
#endif
#include <lib/time.h>
-bool_t test_diff_time(const struct timespec *time1, const struct timespec *time0, double result);
+bool_t test_diff_time(const struct timespec *time1,
+ const struct timespec *time0, double result);
// Meta test function
bool_t TEST_lib_time();