#include <OptIm.h>
Inheritance diagram for Conjecture::OptIm:
****************************************************************
This class provides functionality and data for analyzing features of images of size 31x31 or less.
IMPORTANT: There are two stages of initialization associated with this class (it partially violates the Conjecture programming mandate that all classes be fully initialized by their constructors).
One bit is used to represent each pixel, and is either "on" (black) or "off" (white). Additional "meta" information about each row and column is also maintained, including the number of holes and the number of black pixels. This information can be used to create very efficient feature-detection algorithms.
The 'str' method is a useful debugging tool that shows the information maintained within an instance of this class in a very concise fashion. An example of the output for the call:
optim->str('#','.',7)
which generates:
0111110 0 #...... 1 0 #...... 1 0 #...... 1 0 #...... 1 1 #.###.. 4 1 ##...#. 3 1 #.....# 2 1 #.....# 2 0 .#####. 5 8222222
assuming that 'optim' is an Image* represents a 'b'. The numbers around the borders are interpreted as follows:
IMPORTANT: A "hole" in a line is a sequence of contiguous zero's (off or white bits) enclosed in 1's (on or black bits) on BOTH sides.
FUTURE FIX: Optimization issue. This class currently stores partially redundant information because the PixelLines for columns are repeating pixel information already present in the row PixelLines. However, the column PixelLines are also providing non-redundant information (the metadata). In order to remove this redundancy, we will most likely need to throw away PixelLine and simply use this class as an atomic unit. Instead of a vector of PixelLines, we would maintain an array of pixel data, a parallel array of row hole counts, a parallel array of row black counts, a transposed array of column black counts, and a transposed array of column hole counts. This would improve both space utilization, and the efficiency of 'set' and 'clear' methods.
Public Types | |
typedef std::vector< PixelLine > | PixelMatrix |
Public Member Functions | |
OptIm (const std::vector< unsigned int > &rows, u1 width=PixelLine::MaxPixels) | |
OptIm (const Image *image, const ImageArgs &config) | |
const u1 & | width () const |
const PixelMatrix & | cols () const |
const PixelMatrix & | rows () const |
void | updateMeta () |
int | rblack (u1 i) const |
int | rholes (u1 i) const |
int | cblack (u1 i) const |
int | choles (u1 i) const |
u1 | height () const |
bool | get (u2 x, u2 y) const |
std::string | str (char on= '#', char off= '.') const |
std::string | str (const std::string &title, int valign=0, char on= '#', char off= '.') const |
bool | crop (int level=0) |
bool | crop (int topthick, int bottomthick, int leftthick, int rightthick) |
bool | crop (int topthick, int bottomthick, int leftthick, int rightthick, int &topref, int &bottomref, int &leftref, int &rightref) |
void | identifyFeatures (GlyphFeatures &features) |
const PixelLine & | row (int i) const |
bool | removeBottomSerifs () |
bool | removeTopSerifs () |
void | print (ostream &os=cout) const |
Static Public Member Functions | |
static void | test (int argc=0, const char *argv[]=NULL) |
Protected Member Functions | |
bool | updated () const |
void | updatedIs (const bool &updated) |
void | widthIs (const u1 &width) |
void | colsIs (const PixelMatrix &cols) |
void | rowsIs (const PixelMatrix &rows) |
std::string | rawstr (const PixelMatrix &vec, char on= '1', char off= '0', unsigned char size=PixelLine::MaxPixels) const |
*Obtain a specific writeable PixelLine by row Negative *indexes are relative to the | end (-1 is last index,-2 is *second last, etc.) inline PixelLine &row(int i) |
GlyphFeatures::Variant | analyzeLines (u1 min, u2 max, const PixelMatrix &matrix, u1 dom, u1 rec, u1 halfn) |
Friends | |
class | PixFilt |
|
Number of black pixels in column 'i' |
|
Number of holes in column 'i' |
|
Crop the image An image in which there are no black pixels along any border can be auto-cropped to a smaller image. More aggressive cropping can also be performed, in which continguous regions of "on" pixels that have a matching "on" pixel in the adjacent row/column are turned off (and the result potentially cropped).
|
|
Returns the pixel value at image coord <x,y> (origin at top-left corner of image). |
|
Performs some serious work. Feature detection.
|
|
Number of black pixels in row 'i' |
|
This method performs bottom serif removal on the image. NOTE: metadata is not needed for this method, and it is more efficient if this method is invoked before metadata is computed. |
|
This method performs top serif removal on the image. NOTE: metadata is not needed for this method, and it is more efficient if this method is invoked before metadata is computed. |
|
Number of holes in row 'i' |
|
Obtain a specific const PixelLine by row. Negative indexes are relative to the end (-1 is last index, -2 is second last, etc.) |
|
Create a string representation
|
|
Create printable representation of this OptIm. See the class comments for more details. |