6#include "img2num/Error.h"
11 img2num::clear_last_error_and_catch(img2num::gaussian_blur_fft, image, width, height, sigma);
15 img2num::clear_last_error_and_catch(img2num::invert_image, image, width, height);
19 const int num_thresholds) {
20 img2num::clear_last_error_and_catch(img2num::threshold_image, ptr, width, height,
25 const int num_thresholds) {
26 img2num::clear_last_error_and_catch(img2num::black_threshold_image, ptr, width, height,
30void img2num_kmeans(
const uint8_t *data, uint8_t *out_data, int32_t *out_labels,
31 const int32_t width,
const int32_t height,
const int32_t k,
32 const int32_t max_iter,
const uint8_t color_space) {
33 img2num::clear_last_error_and_catch(img2num::kmeans, data, out_data, out_labels, width, height,
34 k, max_iter, color_space);
38 double sigma_range, uint8_t color_space) {
39 img2num::clear_last_error_and_catch(img2num::bilateral_filter, image, width, height,
40 sigma_spatial, sigma_range, color_space);
44 const int height,
const int min_area) {
45 char *result{
nullptr};
46 img2num::clear_last_error_and_catch(
47 [&](
const uint8_t *d,
const int32_t *l,
const int w,
const int h,
const int min_a) {
48 std::string svg{img2num::labels_to_svg(d, l, w, h, min_a)};
49 result =
static_cast<char *
>(std::malloc(svg.size() + 1));
53 std::memcpy(result, svg.c_str(), svg.size() + 1);
55 data, labels, width, height, min_area);
char * img2num_labels_to_svg(const uint8_t *data, const int32_t *labels, const int width, const int height, const int min_area)
Convert labeled regions of an image into an SVG string.
void img2num_threshold_image(uint8_t *ptr, const int width, const int height, const int num_thresholds)
Apply a thresholding operation to an image.
void img2num_invert_image(uint8_t *image, int width, int height)
Invert the pixel values of an image.
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.
void img2num_black_threshold_image(uint8_t *ptr, const int width, const int height, const int num_thresholds)
Apply black-thresholding to an image.
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.
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.
Core image processing functions for img2num project.