Engauge Digitizer
2
Toggle main menu visibility
Loading...
Searching...
No Matches
util
Pixels.h
Go to the documentation of this file.
1
/******************************************************************************************************
2
* (C) 2018 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3
* under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4
* LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5
******************************************************************************************************/
6
7
#ifndef PIXELS_H
8
#define PIXELS_H
9
10
#include <QMap>
11
#include <QPoint>
12
#include <QQueue>
13
#include <QStack>
14
#include <QString>
15
16
class
QImage;
17
19
typedef
QMap<QString, bool>
HashLookup
;
20
21
typedef
QQueue<QPoint>
QueuedPoints
;
22
24
enum
PixelFillState
{
25
PIXEL_FILL_STATE_UNPROCESSED
,
26
PIXEL_FILL_STATE_IN_PROCESS
,
27
PIXEL_FILL_STATE_PROCESSED
28
};
29
31
class
Pixels
32
{
33
public
:
35
Pixels
();
36
38
int
countBlackPixelsAroundPoint
(
const
QImage &image,
39
int
x,
40
int
y,
41
int
stopCountAt);
42
44
void
fillHole
(QImage &image,
45
int
row,
46
int
col,
47
int
thresholdCount)
const
;
48
51
void
fillHoles
(QImage &image,
52
int
thresholdCount);
53
56
void
fillIsolatedWhitePixels
(QImage &image);
57
59
static
bool
pixelIsBlack
(
const
QImage &image,
60
int
x,
61
int
y);
62
63
private
:
64
65
enum
FillIt {
66
NO_FILL,
67
YES_FILL
68
};
69
70
// Multiple pass algorithm
71
int
fillPass (QImage &image,
72
QVector<PixelFillState> &states,
73
int
row,
74
int
col,
75
PixelFillState
stateFrom,
76
PixelFillState
stateTo,
77
FillIt fillit);
78
QString hashForCoordinates (
int
x,
79
int
y)
const
;
80
int
indexCollapse (
int
row,
81
int
col,
82
int
width)
const
;
83
};
84
85
#endif
// PIXELS_H
HashLookup
QMap< QString, bool > HashLookup
Quick lookup table for pixel coordinate hashes processed so far.
Definition
Pixels.h:19
PixelFillState
PixelFillState
Each pixel transitions from unprocessed, to in-process, to processed.
Definition
Pixels.h:24
PIXEL_FILL_STATE_UNPROCESSED
@ PIXEL_FILL_STATE_UNPROCESSED
Definition
Pixels.h:25
PIXEL_FILL_STATE_IN_PROCESS
@ PIXEL_FILL_STATE_IN_PROCESS
Definition
Pixels.h:26
PIXEL_FILL_STATE_PROCESSED
@ PIXEL_FILL_STATE_PROCESSED
Definition
Pixels.h:27
QueuedPoints
QQueue< QPoint > QueuedPoints
Definition
Pixels.h:21
Pixels::fillIsolatedWhitePixels
void fillIsolatedWhitePixels(QImage &image)
Fill in white pixels surrounded by more black pixels than white pixels.
Definition
Pixels.cpp:155
Pixels::pixelIsBlack
static bool pixelIsBlack(const QImage &image, int x, int y)
Return true if pixel is black in black and white image.
Definition
Pixels.cpp:286
Pixels::countBlackPixelsAroundPoint
int countBlackPixelsAroundPoint(const QImage &image, int x, int y, int stopCountAt)
Fill triangle between these three points.
Definition
Pixels.cpp:16
Pixels::fillHoles
void fillHoles(QImage &image, int thresholdCount)
Fill in white holes, surrounded by black pixels, smaller than some threshold number of pixels.
Definition
Pixels.cpp:108
Pixels::fillHole
void fillHole(QImage &image, int row, int col, int thresholdCount) const
Fill white hole encompassing (row,col) if number of pixels in that hole is below the threshold.
Definition
Pixels.cpp:70
Pixels::Pixels
Pixels()
Single constructor.
Definition
Pixels.cpp:12
Generated on
for Engauge Digitizer by
1.17.0