tesseract v5.3.3.20231005
|
#include <thresholder.h>
Public Member Functions | |
ImageThresholder () | |
virtual | ~ImageThresholder () |
virtual void | Clear () |
Destroy the Pix if there is one, freeing memory. More... | |
bool | IsEmpty () const |
Return true if no image has been set. More... | |
void | SetImage (const unsigned char *imagedata, int width, int height, int bytes_per_pixel, int bytes_per_line) |
void | SetRectangle (int left, int top, int width, int height) |
virtual void | GetImageSizes (int *left, int *top, int *width, int *height, int *imagewidth, int *imageheight) |
bool | IsColor () const |
Return true if the source image is color. More... | |
bool | IsBinary () const |
Returns true if the source image is binary. More... | |
int | GetScaleFactor () const |
void | SetSourceYResolution (int ppi) |
int | GetSourceYResolution () const |
int | GetScaledYResolution () const |
void | SetEstimatedResolution (int ppi) |
int | GetScaledEstimatedResolution () const |
void | SetImage (const Image pix) |
virtual bool | ThresholdToPix (Image *pix) |
Returns false on error. More... | |
virtual std::tuple< bool, Image, Image, Image > | Threshold (TessBaseAPI *api, ThresholdMethod method) |
virtual Image | GetPixRectThresholds () |
Image | GetPixRect () |
virtual Image | GetPixRectGrey () |
Protected Member Functions | |
virtual void | Init () |
Common initialization shared between SetImage methods. More... | |
bool | IsFullImage () const |
Return true if we are processing the full image. More... | |
void | OtsuThresholdRectToPix (Image src_pix, Image *out_pix) const |
void | ThresholdRectToPix (Image src_pix, int num_channels, const std::vector< int > &thresholds, const std::vector< int > &hi_values, Image *pix) const |
Protected Attributes | |
Image | pix_ |
int | image_width_ |
Width of source pix_. More... | |
int | image_height_ |
Height of source pix_. More... | |
int | pix_channels_ |
Number of 8-bit channels in pix_. More... | |
int | pix_wpl_ |
Words per line of pix_. More... | |
int | scale_ |
Scale factor from original image. More... | |
int | yres_ |
y pixels/inch in source image. More... | |
int | estimated_res_ |
Resolution estimate from text size. More... | |
int | rect_left_ |
int | rect_top_ |
int | rect_width_ |
int | rect_height_ |
Base class for all tesseract image thresholding classes. Specific classes can add new thresholding methods by overriding ThresholdToPix. Each instance deals with a single image, but the design is intended to be useful for multiple calls to SetRectangle and ThresholdTo* if desired.
Definition at line 45 of file thresholder.h.
tesseract::ImageThresholder::ImageThresholder | ( | ) |
Definition at line 42 of file thresholder.cpp.
|
virtual |
Definition at line 54 of file thresholder.cpp.
|
virtual |
Destroy the Pix if there is one, freeing memory.
Definition at line 59 of file thresholder.cpp.
|
virtual |
Get enough parameters to be able to rebuild bounding boxes in the original image (not just within the rectangle). Left and top are enough with top-down coordinates, but the height of the rectangle and the image are needed for bottom-up.
Definition at line 148 of file thresholder.cpp.
Image tesseract::ImageThresholder::GetPixRect | ( | ) |
Get a clone/copy of the source image rectangle. The returned Pix must be pixDestroyed. This function will be used in the future by the page layout analysis, and the layout analysis that uses it will only be available with Leptonica, so there is no raw equivalent.
Definition at line 351 of file thresholder.cpp.
|
virtual |
Definition at line 368 of file thresholder.cpp.
|
virtual |
Definition at line 324 of file thresholder.cpp.
|
inline |
Definition at line 115 of file thresholder.h.
|
inline |
Definition at line 102 of file thresholder.h.
|
inline |
Definition at line 88 of file thresholder.h.
|
inline |
Definition at line 99 of file thresholder.h.
|
protectedvirtual |
Common initialization shared between SetImage methods.
Definition at line 342 of file thresholder.cpp.
|
inline |
Returns true if the source image is binary.
Definition at line 84 of file thresholder.h.
|
inline |
Return true if the source image is color.
Definition at line 79 of file thresholder.h.
bool tesseract::ImageThresholder::IsEmpty | ( | ) | const |
Return true if no image has been set.
Definition at line 64 of file thresholder.cpp.
|
inlineprotected |
Return true if we are processing the full image.
Definition at line 165 of file thresholder.h.
|
protected |
Definition at line 385 of file thresholder.cpp.
|
inline |
Definition at line 110 of file thresholder.h.
void tesseract::ImageThresholder::SetImage | ( | const Image | pix | ) |
Pix vs raw, which to use? Pix is the preferred input for efficiency, since raw buffers are copied. SetImage for Pix clones its input, so the source pix may be pixDestroyed immediately after, but may not go away until after the Thresholder has finished with it.
Definition at line 163 of file thresholder.cpp.
void tesseract::ImageThresholder::SetImage | ( | const unsigned char * | imagedata, |
int | width, | ||
int | height, | ||
int | bytes_per_pixel, | ||
int | bytes_per_line | ||
) |
SetImage makes a copy of all the image data, so it may be deleted immediately after this call. Greyscale of 8 and color of 24 or 32 bits per pixel may be given. Palette color images will not work properly and must be converted to 24 bit. Binary images of 1 bit per pixel may also be given but they must be byte packed with the MSB of the first byte being the first pixel, and a one pixel is WHITE. For binary images set bytes_per_pixel=0.
Definition at line 76 of file thresholder.cpp.
void tesseract::ImageThresholder::SetRectangle | ( | int | left, |
int | top, | ||
int | width, | ||
int | height | ||
) |
Store the coordinates of the rectangle to process for later use. Doesn't actually do any thresholding.
Definition at line 137 of file thresholder.cpp.
|
inline |
Definition at line 95 of file thresholder.h.
|
virtual |
Definition at line 186 of file thresholder.cpp.
|
protected |
Threshold the rectangle, taking everything except the src_pix from the class, using thresholds/hi_values to the output pix. NOTE that num_channels is the size of the thresholds and hi_values
Definition at line 410 of file thresholder.cpp.
|
virtual |
Returns false on error.
Threshold the source image as efficiently as possible to the output Pix. Creates a Pix and sets pix to point to the resulting pointer. Caller must use pixDestroy to free the created Pix. Returns false on error.
Definition at line 285 of file thresholder.cpp.
|
protected |
Resolution estimate from text size.
Definition at line 192 of file thresholder.h.
|
protected |
Height of source pix_.
Definition at line 186 of file thresholder.h.
|
protected |
Width of source pix_.
Definition at line 185 of file thresholder.h.
|
protected |
Clone or other copy of the source Pix. The pix will always be PixDestroy()ed on destruction of the class.
Definition at line 183 of file thresholder.h.
|
protected |
Number of 8-bit channels in pix_.
Definition at line 187 of file thresholder.h.
|
protected |
Words per line of pix_.
Definition at line 188 of file thresholder.h.
|
protected |
Definition at line 196 of file thresholder.h.
|
protected |
Definition at line 193 of file thresholder.h.
|
protected |
Definition at line 194 of file thresholder.h.
|
protected |
Definition at line 195 of file thresholder.h.
|
protected |
Scale factor from original image.
Definition at line 190 of file thresholder.h.
|
protected |
y pixels/inch in source image.
Definition at line 191 of file thresholder.h.