OCRudoku
v1.0
Resolve word grid with ease
|
#include <err.h>
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "Spliting.h"
#include "../Image/ImageUtils.h"
#include "../Application/ApplicationUtils.h"
Macros | |
#define | _GNU_SOURCE |
Functions | |
int | get_grid_vertical_nb (SDL_Surface *surface, SDL_Rect rect) |
Calculates the number of vertical grid splits in a given SDL surface. | |
int * | get_grid_vertical_split (SDL_Surface *surface, SDL_Rect rect, int *nb_splits) |
Calculates the vertical split positions in a given SDL surface. | |
int | get_grid_horizontal_nb (SDL_Surface *surface, SDL_Rect rect) |
Calculates the number of horizontal grid splits in a given SDL surface. | |
int * | get_grid_horizontal_split (SDL_Surface *surface, SDL_Rect rect, int *nb_splits) |
Calculates the horizontal split positions in a given SDL surface. | |
SDL_Rect ** | get_grid_split (SDL_Surface *surface, SDL_Rect rect, int *first_dim, int *second_dim) |
Splits a given SDL surface into a grid of rectangles. | |
SDL_Rect ** | get_word_list_split (SDL_Surface *surface, SDL_Rect rect, int *word_nb) |
Splits a given SDL surface into a list of words. | |
void | export_split_grid (SDL_Surface *surface, SDL_Rect rect, const char *save_dir) |
Exports the split grid of a given SDL surface to a specified directory. | |
void | export_split_word_list (SDL_Surface *surface, SDL_Rect rect, const char *save_dir) |
Exports the split word list of a given SDL surface to a specified directory. | |
int | get_bin_pixel (SDL_Surface *surface, int x, int y) |
void | get_cluster_size (SDL_Surface *surface, int *x, int *y, int *w, int *h, int currx, int curry, int visited[surface->w][surface->h]) |
void | copy_cluster_aux (SDL_Surface *surface, SDL_Surface *new_surface, int x, int y, int sx, int sy, int visited[]) |
SDL_Surface * | copy_cluster (SDL_Surface *surface, pixel_cluster cluster_rect) |
pixel_cluster * | get_clusters (SDL_Surface *surface, size_t *cluster_nb) |
pixel_cluster * | filter_primary_clusters (pixel_cluster *clusters, size_t nb_clusters, size_t *filtered_nb) |
void | get_cluster_center (pixel_cluster cluster, int *x, int *y) |
double | distance_between (int x1, int y1, int x2, int y2) |
void | get_cluster_linkage_count_aux (pixel_cluster *clusters, size_t start, size_t cluster_nb, size_t *linkage_nb, double distance, double margin, int visited[cluster_nb]) |
void | get_cluster_linkage_aux (pixel_cluster *clusters, size_t start, size_t cluster_nb, size_t *current_linkage, pixel_cluster *arr, double distance, double margin, int visited[cluster_nb]) |
pixel_cluster * | get_cluster_linkage (pixel_cluster *clusters, size_t start, size_t cluster_nb, size_t *linkage_nb, int visited[cluster_nb]) |
pixel_cluster ** | get_clusters_linkages (pixel_cluster *clusters, size_t cluster_nb, size_t *nb_linkages, size_t **linkage_len) |
size_t | get_grid_cluster (size_t nb_linkages, size_t *linkage_len) |
void | export_word_cluster (SDL_Surface *surface, pixel_cluster *clusters, size_t cluster_nb, size_t word_nb, char *word_dir) |
int | same_pos (int pos1, int pos2, int margin) |
void | export_grid_cluster (SDL_Surface *surface, pixel_cluster *clusters, size_t cluster_nb, char *grid_dir, int *sx, int *sy) |
pixel_cluster ** | get_main_linkages (SDL_Surface *surface, size_t *nb_linkages, size_t **linkages_len) |
void | export_main_linkages (SDL_Surface *surface, pixel_cluster **linkages, size_t nb_linkages, size_t *linkages_len, char *res_dir, int *sx, int *sy) |
SDL_Rect | get_grid_rect (pixel_cluster *linkages, size_t nb_linkages) |
Variables | |
int | split_margin = 0 |
#define _GNU_SOURCE |
SDL_Surface * copy_cluster | ( | SDL_Surface * | surface, |
pixel_cluster | cluster_rect ) |
void copy_cluster_aux | ( | SDL_Surface * | surface, |
SDL_Surface * | new_surface, | ||
int | x, | ||
int | y, | ||
int | sx, | ||
int | sy, | ||
int | visited[] ) |
double distance_between | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2 ) |
void export_grid_cluster | ( | SDL_Surface * | surface, |
pixel_cluster * | clusters, | ||
size_t | cluster_nb, | ||
char * | grid_dir, | ||
int * | sx, | ||
int * | sy ) |
void export_main_linkages | ( | SDL_Surface * | surface, |
pixel_cluster ** | linkages, | ||
size_t | nb_linkages, | ||
size_t * | linkages_len, | ||
char * | res_dir, | ||
int * | sx, | ||
int * | sy ) |
void export_split_grid | ( | SDL_Surface * | surface, |
SDL_Rect | rect, | ||
const char * | save_dir ) |
Exports the split grid of a given SDL surface to a specified directory.
This function splits the specified rectangular area of the SDL surface into a grid based on the brightness threshold defined by split_margin
. It then exports each split area as a PNG image to the specified directory.
surface | The SDL_Surface to analyze and split. |
rect | The SDL_Rect defining the area of the surface to analyze and split. |
save_dir | The directory where the split images will be saved. |
void export_split_word_list | ( | SDL_Surface * | surface, |
SDL_Rect | rect, | ||
const char * | save_dir ) |
Exports the split word list of a given SDL surface to a specified directory.
This function splits the specified rectangular area of the SDL surface into a list of words based on the brightness threshold defined by split_margin
. It then exports each split word as a PNG image to the specified directory.
surface | The SDL_Surface to analyze and split. |
rect | The SDL_Rect defining the area of the surface to analyze and split. |
save_dir | The directory where the split images will be saved. |
void export_word_cluster | ( | SDL_Surface * | surface, |
pixel_cluster * | clusters, | ||
size_t | cluster_nb, | ||
size_t | word_nb, | ||
char * | word_dir ) |
pixel_cluster * filter_primary_clusters | ( | pixel_cluster * | clusters, |
size_t | nb_clusters, | ||
size_t * | filtered_nb ) |
int get_bin_pixel | ( | SDL_Surface * | surface, |
int | x, | ||
int | y ) |
void get_cluster_center | ( | pixel_cluster | cluster, |
int * | x, | ||
int * | y ) |
pixel_cluster * get_cluster_linkage | ( | pixel_cluster * | clusters, |
size_t | start, | ||
size_t | cluster_nb, | ||
size_t * | linkage_nb, | ||
int | visited[cluster_nb] ) |
void get_cluster_linkage_aux | ( | pixel_cluster * | clusters, |
size_t | start, | ||
size_t | cluster_nb, | ||
size_t * | current_linkage, | ||
pixel_cluster * | arr, | ||
double | distance, | ||
double | margin, | ||
int | visited[cluster_nb] ) |
void get_cluster_linkage_count_aux | ( | pixel_cluster * | clusters, |
size_t | start, | ||
size_t | cluster_nb, | ||
size_t * | linkage_nb, | ||
double | distance, | ||
double | margin, | ||
int | visited[cluster_nb] ) |
void get_cluster_size | ( | SDL_Surface * | surface, |
int * | x, | ||
int * | y, | ||
int * | w, | ||
int * | h, | ||
int | currx, | ||
int | curry, | ||
int | visited[surface->w][surface->h] ) |
pixel_cluster * get_clusters | ( | SDL_Surface * | surface, |
size_t * | cluster_nb ) |
pixel_cluster ** get_clusters_linkages | ( | pixel_cluster * | clusters, |
size_t | cluster_nb, | ||
size_t * | nb_linkages, | ||
size_t ** | linkage_len ) |
size_t get_grid_cluster | ( | size_t | nb_linkages, |
size_t * | linkage_len ) |
int get_grid_horizontal_nb | ( | SDL_Surface * | surface, |
SDL_Rect | rect ) |
Calculates the number of horizontal grid splits in a given SDL surface.
This function analyzes the brightness of pixels in the specified rectangular area of the SDL surface and determines the number of horizontal splits based on the brightness threshold defined by split_margin
.
surface | The SDL_Surface to analyze. |
rect | The SDL_Rect defining the area of the surface to analyze. |
int * get_grid_horizontal_split | ( | SDL_Surface * | surface, |
SDL_Rect | rect, | ||
int * | nb_splits ) |
Calculates the horizontal split positions in a given SDL surface.
This function analyzes the brightness of pixels in the specified rectangular area of the SDL surface and determines the positions of horizontal splits based on the brightness threshold defined by split_margin
.
surface | The SDL_Surface to analyze. |
rect | The SDL_Rect defining the area of the surface to analyze. |
nb_splits | Pointer to an integer where the number of splits will be stored. |
SDL_Rect get_grid_rect | ( | pixel_cluster * | linkages, |
size_t | nb_linkages ) |
SDL_Rect ** get_grid_split | ( | SDL_Surface * | surface, |
SDL_Rect | rect, | ||
int * | first_dim, | ||
int * | second_dim ) |
Splits a given SDL surface into a grid of rectangles.
This function analyzes the brightness of pixels in the specified rectangular area of the SDL surface and determines the positions of vertical and horizontal splits based on the brightness threshold defined by split_margin
. It then creates a grid of SDL_Rect structures representing the split areas.
surface | The SDL_Surface to analyze. |
rect | The SDL_Rect defining the area of the surface to analyze. |
first_dim | Pointer to an integer where the number of horizontal splits will be stored. |
second_dim | Pointer to an integer where the number of vertical splits will be stored. |
int get_grid_vertical_nb | ( | SDL_Surface * | surface, |
SDL_Rect | rect ) |
Calculates the number of vertical grid splits in a given SDL surface.
This function analyzes the brightness of pixels in the specified rectangular area of the SDL surface and determines the number of vertical splits based on the brightness threshold defined by split_margin
.
surface | The SDL_Surface to analyze. |
rect | The SDL_Rect defining the area of the surface to analyze. |
int * get_grid_vertical_split | ( | SDL_Surface * | surface, |
SDL_Rect | rect, | ||
int * | nb_splits ) |
Calculates the vertical split positions in a given SDL surface.
This function analyzes the brightness of pixels in the specified rectangular area of the SDL surface and determines the positions of vertical splits based on the brightness threshold defined by split_margin
.
surface | The SDL_Surface to analyze. |
rect | The SDL_Rect defining the area of the surface to analyze. |
nb_splits | Pointer to an integer where the number of splits will be stored. |
pixel_cluster ** get_main_linkages | ( | SDL_Surface * | surface, |
size_t * | nb_linkages, | ||
size_t ** | linkages_len ) |
SDL_Rect ** get_word_list_split | ( | SDL_Surface * | surface, |
SDL_Rect | rect, | ||
int * | word_nb ) |
Splits a given SDL surface into a list of words.
This function analyzes the brightness of pixels in the specified rectangular area of the SDL surface and determines the positions of vertical splits based on the brightness threshold defined by split_margin
. It then creates a list of SDL_Rect structures representing the split words.
surface | The SDL_Surface to analyze. |
rect | The SDL_Rect defining the area of the surface to analyze. |
word_nb | Pointer to an integer where the number of words will be stored. |
int same_pos | ( | int | pos1, |
int | pos2, | ||
int | margin ) |
int split_margin = 0 |