| 6 |
| obtaining a copy of this software and associated documentation |
| 7 | files (the "Software"), to deal in the Software without |
| 8 | restriction, including without limitation the rights to use, |
| 9 | copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | copies of the Software, and to permit persons to whom the |
| 11 | Software is furnished to do so, subject to the following |
| 12 | conditions: |
| 13 |
| 14 | The above copyright notice and this permission notice shall be |
| 15 | included in all copies or substantial portions of the Software. |
| 16 |
| 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
| 19 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
| 21 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 24 | OTHER DEALINGS IN THE SOFTWARE. |
| 25 | */ |
| 26 |
| 27 | #ifndef _FASTEDGE |
| 28 | #define _FASTEDGE |
| 29 |
| 30 | namespace ocr{ |
| 31 | //#define WIDTH 640 // uncomment to define width for situations where width is always known |
| 32 | //#define HEIGHT 480 // uncomment to define heigh for situations where height is always known |
| 33 |
| 34 | //#define CLOCK // uncomment to show running times of image processing functions (in seconds) |
| 35 | //#define ABS_APPROX // uncomment to use the absolute value approximation of sqrt(Gx ^ 2 + Gy ^2) |
| 36 | //#define PRINT_HISTOGRAM // uncomment to print the histogram used to estimate the threshold |
| 37 | struct image { |
| 38 | int width; |
| 39 | int height; |
| 40 | unsigned char * pixel_data; |
| 41 | }; |
| 42 |
| 43 | void canny_edge_detect(struct image * img_in, struct image * img_out); |
| 44 | void gaussian_noise_reduce(struct image * img_in, struct image * img_out); |
| 45 | void calc_gradient_sobel(struct image * img_in, int g[], int dir[]); |
| 46 | void calc_gradient_scharr(struct image * img_in, int g_x[], int g_y[], int g[], int dir[]); |
| 47 | void non_max_suppression(struct image * img, int g[], int dir[]); |
| 48 | void estimate_threshold(struct image * img, int * high, int * low); |
| 49 | void hysteresis (int high, int low, struct image * img_in, struct image * img_out); |
| 50 | int trace (int x, int y, int low, struct image * img_in, struct image * img_out); |
| 51 | int range (struct image * img, int x, int y); |
| 52 | void dilate_1d_h(struct image * img, struct image * img_out); |
| 53 | void dilate_1d_v(struct image * img, struct image * img_out); |
| 54 | void erode_1d_h(struct image * img, struct image * img_out); |
| 55 | void erode_1d_v(struct image * img, struct image * img_out); |
| 56 | void erode(struct image * img_in, struct image * img_scratch, struct image * img_out); |
| 57 | void dilate(struct image * img_in, struct image * img_scratch, struct image * img_out); |
| 58 | void morph_open(struct image * img_in, struct image * img_scratch, struct image * img_scratch2, struct image * img_out); |
| 59 | void morph_close(struct image * img_in, struct image * img_scratch, struct image * img_scratch2, struct image * img_out); |
| 60 | } |
| 61 | #endif |
| 62 |