-
Notifications
You must be signed in to change notification settings - Fork 0
/
vc.h
139 lines (102 loc) · 4.08 KB
/
vc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// INSTITUTO POLIT�CNICO DO C�VADO E DO AVE
// 2022/2023
// ENGENHARIA DE SISTEMAS INFORM�TICOS
// VIS�O POR COMPUTADOR
//
// [ DUARTE DUQUE - [email protected] ]
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#define VC_DEBUG
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ESTRUTURA DE UMA IMAGEM
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
typedef struct {
unsigned char *data;
int width, height;
int channels; // Bin�rio/Cinzentos=1; RGB=3
int levels; // Bin�rio=1; Cinzentos [1,255]; RGB [1,255]
int bytesperline; // widchth * channels
} IVC;
// Estrutura do BLOB
typedef struct {
int x, y, width, height; // Caixa delimitadora (Bounding Box)
int area; // Área
int xc, yc; // Centro-de-massa
int perimeter; // Perimetro
int label; // Etiqueta
unsigned char *mask; // Não usado
unsigned char *data; // Não usado
int channels; // Não usado
int levels; // Não usado
} OVC;
typedef struct {
unsigned char red;
unsigned char green;
unsigned char blue;
} RGB;
// Estrutura para o min e max do hsv
typedef struct {
int hmin;
int hmax;
int smin;
int smax;
int vmin;
int vmax;
int erosao;
int dilatacao;
int minBlobArea;
} HSV;
// Estrutura para salvar as cores entradas
typedef struct {
int color;
int x;
} CoresEncontradas;
//Estrutura para contar quantas resistencias tem de cada tipo
typedef struct {
int potencia;
int count;
} ResistenciasEncontradas;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Macros
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// PROTOTIPOS DE FUNÇÕES
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// FUNÇÕES: ALOCAR E LIBERTAR UMA IMAGEM
IVC *vc_image_new(int width, int height, int channels, int levels);
IVC *vc_image_free(IVC *image);
// FUNÇÕES: LEITURA E ESCRITA DE IMAGENS (PBM, PGM E PPM)
IVC *vc_read_image(char *filename);
int vc_write_image(char *filename, IVC *image);
int vc_gray_negative(IVC *srcdst);
int vc_rgb_negative(IVC* srcdst);
int vc_rgb_get_red_gray(IVC *srcdst);
int vc_rgb_get_green_gray(IVC *srcdst);
int vc_rgb_get_blue_gray(IVC *srcdst);
int vc_rgb_to_gray(IVC *src, IVC *dst);
int vc_rgb_to_hsv(IVC *src, IVC *dst);
// hmin,hmax = [0, 360]; smin,smax = [0, 100]; vmin,vmax = [0, 100]
int vc_hsv_segmentation(IVC *src, IVC *dst, int hmin, int hmax, int smin,
int smax, int vmin, int vmax, int *found);
int vc_scale_gray_to_color_palette(IVC *src, IVC *dst);
int vc_image_white_pixel_count(IVC *src);
int vc_gray_to_binary(IVC *src, IVC *dst, int threshold);
int vc_gray_to_binary_global_mean(IVC *src, IVC *dst);
int vc_gray_to_binary_midpoint(IVC *src, IVC *dst, int kernel);
int vc_gray_to_binary_niblac(IVC *src, IVC *dst, int kernel, float k);
int vc_binary_erode(IVC *src, IVC *dst, int kernel);
int vc_binary_dilate(IVC *src, IVC *dst, int kernel);
int vc_binary_open(IVC *src, IVC *dst, int kernelErode, int kernelDilate);
int vc_binary_close(IVC *src, IVC *dst, int kernelErode, int kernelDilate);
OVC* vc_binary_blob_labelling(IVC *src, IVC *dst, int *nlabels);
int vc_binary_blob_info(IVC *src, OVC *blobs, int nblobs);
int vc_blob_to_gray_scale(IVC *src, IVC *dst, int nlabels);
int vc_blob_to_gray_rgb(IVC *src, IVC *dst, int nlabels);
int vc_draw_center_of_gravity(unsigned char *data, OVC *blob, int width, int height, int comp);
int vc_draw_bounding_box(unsigned char *data, OVC *blob, int width, int height);
int vc_gray_histogram_show(IVC *src, IVC *dst);
int vc_gray_histogram_equalization(IVC *src, IVC *dst);
//converter bgr para rgb
int vc_convert_bgr_to_rgb(IVC *src, IVC *dst);