Img2Num C
API Documentation
cimg2num.cpp
Go to the documentation of this file.
1 #include "cimg2num.h"
2 
3 #include "img2num.h"
4 #include "img2num/Error.h"
5 
6 extern "C" {
7 
8 void img2num_gaussian_blur_fft(uint8_t *image, size_t width, size_t height, double sigma) {
9  img2num::clear_last_error_and_catch(img2num::gaussian_blur_fft, image, width, height, sigma);
10 }
11 
12 void img2num_invert_image(uint8_t *image, int width, int height) {
13  img2num::clear_last_error_and_catch(img2num::invert_image, image, width, height);
14 }
15 
16 void img2num_threshold_image(uint8_t *ptr, const int width, const int height,
17  const int num_thresholds) {
18  img2num::clear_last_error_and_catch(img2num::threshold_image, ptr, width, height,
19  num_thresholds);
20 }
21 
22 void img2num_black_threshold_image(uint8_t *ptr, const int width, const int height,
23  const int num_thresholds) {
24  img2num::clear_last_error_and_catch(img2num::black_threshold_image, ptr, width, height,
25  num_thresholds);
26 }
27 
28 void img2num_kmeans(const uint8_t *data, uint8_t *out_data, int32_t *out_labels,
29  const int32_t width, const int32_t height, const int32_t k,
30  const int32_t max_iter, const uint8_t color_space) {
31  img2num::clear_last_error_and_catch(img2num::kmeans, data, out_data, out_labels, width, height,
32  k, max_iter, color_space);
33 }
34 
35 void img2num_bilateral_filter(uint8_t *image, size_t width, size_t height, double sigma_spatial,
36  double sigma_range, uint8_t color_space) {
37  img2num::clear_last_error_and_catch(img2num::bilateral_filter, image, width, height,
38  sigma_spatial, sigma_range, color_space);
39 }
40 
41 char *img2num_labels_to_svg(uint8_t *data, int32_t *labels, const int width, const int height,
42  const int min_area, const bool draw_contour_borders) {
43  char *result{nullptr};
44  img2num::clear_last_error_and_catch(
45  [&](uint8_t *d, int32_t *l, int w, int h, int min_a, bool draw_contours) {
46  result = img2num::labels_to_svg(d, l, w, h, min_a, draw_contours);
47  },
48  data, labels, width, height, min_area, draw_contour_borders);
49  return result;
50 }
51 }
char * img2num_labels_to_svg(uint8_t *data, int32_t *labels, const int width, const int height, const int min_area, const bool draw_contour_borders)
Convert labeled regions of an image into an SVG string.
Definition: cimg2num.cpp:41
void img2num_threshold_image(uint8_t *ptr, const int width, const int height, const int num_thresholds)
Apply a thresholding operation to an image.
Definition: cimg2num.cpp:16
void img2num_invert_image(uint8_t *image, int width, int height)
Invert the pixel values of an image.
Definition: cimg2num.cpp:12
void img2num_gaussian_blur_fft(uint8_t *image, size_t width, size_t height, double sigma)
Apply a Gaussian blur to an image using FFT.
Definition: cimg2num.cpp:8
void img2num_black_threshold_image(uint8_t *ptr, const int width, const int height, const int num_thresholds)
Apply black-thresholding to an image.
Definition: cimg2num.cpp:22
void img2num_kmeans(const uint8_t *data, uint8_t *out_data, int32_t *out_labels, const int32_t width, const int32_t height, const int32_t k, const int32_t max_iter, const uint8_t color_space)
Perform k-means clustering on image data.
Definition: cimg2num.cpp:28
void img2num_bilateral_filter(uint8_t *image, size_t width, size_t height, double sigma_spatial, double sigma_range, uint8_t color_space)
Apply bilateral filtering to an image.
Definition: cimg2num.cpp:35
Core image processing functions for img2num project.