aboutsummaryrefslogtreecommitdiff
path: root/lib/seg/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/seg/util.c')
-rw-r--r--lib/seg/util.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/lib/seg/util.c b/lib/seg/util.c
index a9db067..8af8199 100644
--- a/lib/seg/util.c
+++ b/lib/seg/util.c
@@ -1,6 +1,5 @@
#include <assert.h>
#include <lib/algo/flood_fill.h>
-#include <lib/mem/galloc.h>
#include <lib/png.h>
#include <lib/seg/util.h>
#include <stdio.h>
@@ -81,8 +80,8 @@ MaskData_t *_dilate(const Mask *mask) {
}
}
MaskData_t *ret_mask = new_mask->image[0];
- g_free(new_mask->image);
- g_free(new_mask);
+ free(new_mask->image);
+ free(new_mask);
return ret_mask;
}
@@ -90,7 +89,7 @@ MaskData_t *_dilate(const Mask *mask) {
void dilate(Mask *mask) {
MaskData_t *new_mask = _dilate(mask);
if (new_mask != NULL) {
- g_free(mask->image[0]);
+ free(mask->image[0]);
for (size_t y = 0; y < mask->height; y++) {
mask->image[y] = &(new_mask[y * mask->width]);
}
@@ -133,8 +132,8 @@ MaskData_t *_erode(const Mask *mask) {
}
}
MaskData_t *ret_mask = new_mask->image[0];
- g_free(new_mask->image);
- g_free(new_mask);
+ free(new_mask->image);
+ free(new_mask);
return ret_mask;
}
@@ -142,7 +141,7 @@ MaskData_t *_erode(const Mask *mask) {
void erode(Mask *mask) {
MaskData_t *new_mask = _erode(mask);
if (new_mask != NULL) {
- g_free(mask->image[0]);
+ free(mask->image[0]);
for (size_t y = 0; y < mask->height; y++) {
mask->image[y] = &(new_mask[y * mask->width]);
}
@@ -170,8 +169,8 @@ MaskData_t *_closeup(Mask *mask, size_t num_pixels) {
}
}
MaskData_t *ret_mask = new_mask->image[0];
- g_free(new_mask->image);
- g_free(new_mask);
+ free(new_mask->image);
+ free(new_mask);
return ret_mask;
}
@@ -180,7 +179,7 @@ MaskData_t *_closeup(Mask *mask, size_t num_pixels) {
void closeup(Mask *mask, size_t num_pixels) {
MaskData_t *new_mask = _closeup(mask, num_pixels);
if (new_mask != NULL) {
- g_free(mask->image[0]);
+ free(mask->image[0]);
for (size_t y = 0; y < mask->height; y++) {
mask->image[y] = &(new_mask[y * mask->width]);
}
@@ -228,7 +227,7 @@ Mask *tif_to_labels(char *tif_file_name, MaskData_t *starting_label_p) {
channels = (STRIP_LENGTH * STRIP_COUNT) / (width * height);
//-TIFF-LOAD-DATA--------------------------------
- void *buffer = g_malloc(STRIP_LENGTH * sizeof(ImageData_t));
+ void *buffer = malloc(STRIP_LENGTH * sizeof(ImageData_t));
if (buffer == NULL) {
fprintf(stderr, "Memory allocation error\n");
TIFFClose(tif);
@@ -237,7 +236,7 @@ Mask *tif_to_labels(char *tif_file_name, MaskData_t *starting_label_p) {
Image *image = create_image(width, height, channels);
if (image == NULL) {
fprintf(stderr, "Memory allocation error\n");
- g_free(buffer);
+ free(buffer);
TIFFClose(tif);
return NULL;
}
@@ -248,7 +247,7 @@ Mask *tif_to_labels(char *tif_file_name, MaskData_t *starting_label_p) {
image->image[0][0][x + y * STRIP_LENGTH] = ((ImageData_t *)buffer)[x];
}
}
- g_free(buffer);
+ free(buffer);
//-FLOOD-FILL-SEGMENTATION-----------------------
//-CONTIGUOUS-REGION-FINDING---------------------
@@ -280,13 +279,13 @@ Bitmap *image_mask_data_to_bitmap(const Mask *mask) {
MaskData_t *buffer = mask->image[0];
uint32_t width = mask->width;
uint32_t height = mask->height;
- Pixel *out_buffer = (Pixel *)g_calloc(width * height, sizeof(Pixel));
+ Pixel *out_buffer = (Pixel *)calloc(width * height, sizeof(Pixel));
if (out_buffer == NULL) {
return NULL;
}
- Bitmap *bitmap = (Bitmap *)g_malloc(sizeof(Bitmap));
+ Bitmap *bitmap = (Bitmap *)malloc(sizeof(Bitmap));
if (bitmap == NULL) {
- g_free(out_buffer);
+ free(out_buffer);
return NULL;
}
for (size_t y = 0; y < height; y++) {
@@ -312,7 +311,7 @@ MaskData_t *_reduce_contiguous_regions(MaskData_t *masks, uint32_t width,
MaskData_t *total_labels) {
MaskData_t starting_label = 1;
MaskData_t *new_masks =
- (MaskData_t *)g_calloc(width * height, sizeof(MaskData_t));
+ (MaskData_t *)calloc(width * height, sizeof(MaskData_t));
if (new_masks == NULL) {
return NULL;
}
@@ -342,7 +341,7 @@ void reduce_contiguous_regions(Mask *mask, MaskData_t *total_labels) {
MaskData_t *new_masks = _reduce_contiguous_regions(
mask->image[0], mask->width, mask->height, total_labels);
if (new_masks != NULL) {
- g_free(mask->image[0]);
+ free(mask->image[0]);
for (size_t y = 0; y < mask->height; y++) {
mask->image[y] = &new_masks[y * mask->width];
}