65 return cv::Size(this->cols, this->rows);
87 if (cols == width && rows == height)
90 if (cols > width && rows > height)
91 cv::resize(*
this, *
this, cv::Size(width, height), 0, 0, cv::INTER_AREA);
93 cv::resize(*
this, *
this, cv::Size(width, height), 0, 0,
interpolation);
127 this->
Resize(width, height);
250 Cm_Assert(
image.channels() == 1,
"the image is a single channel image!!!");
282 return cv::mean(
image).val[0];
309 for (
size_t row = 0;
row < rows; ++
row) {
374 cv::Mat kernel = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(
dilate_size, 1));
380 std::vector<std::vector<cv::Point>>
contours;
424 std::vector<cv::Vec4i> lines;
453 if (this->
empty() || lines.empty())
461 Cm_Assert(lines.
Filter([line_type](
const cm::Line&
line) { return line.Type() == line_type; }).size() == lines.size(),
Sprintf(
"The line type in the line list must all be \"%s\"!!!", line_type ==
HLINE ?
"cm::HLINE" :
"cm::VLINE"));
467 for (
auto&
line : lines) {
484 Cm_Assert(lines.
Filter([line_type](
const cm::Line&
line) { return line.Type() == line_type; }).size() == lines.size(),
Sprintf(
"The line type in the line list must all be \"%s\"!!!", line_type ==
HLINE ?
"cm::HLINE" :
"cm::VLINE"));
490 for (
auto&
line : lines) {
519 throw Exception(
"The type(LineType) of param \"line_type\" is incorrect!");
551 std::vector<std::vector<cv::Point>>
contours;
563 cv::drawContours(
mask,
contours,
i, cv::Scalar(255, 255, 255), cv::FILLED);
593 Cm_Assert(this->
channels() == 3,
"the image must be an RGB three-channel image!!!");
645 float range[] = {0, 256};
Image SeparateColor(SeparatedColorType type) const
提取指定颜色像素图像
Image & Scale(double factor, int interpolation=cv::INTER_LINEAR)
缩放图像
Lines GetLines(LineType line_type, const ImagePreprocessor &imp, int threshold, double min_line_length, double max_line_gap=10) const
通过霍夫变换获取线
Image InvertColorRegion(double min_area=7000) const
反转图像中的彩色块
Image & ModifyLinesAreaValue(LineType line_type, const Lines &lines, int pixel_margin=2, uchar pixel_value=0)
修改图像中线所在区域的灰度值
Image GetGrayHistogram() const
计算图像的灰度直方图
Image & Resize(size_t height, size_t width, int interpolation=cv::INTER_LINEAR)
重新设置图像大小
Rects GetTextAreaOutline(size_t dilate_size, double max_aspect_ratio=30) const
获取文本区域轮廓
Image & RmRedBlueStamp(uchar bg_gray_value=255)
删除图像中的红色和蓝色印章
Image & RmRedStamp(uchar bg_gray_value=255)
删除图像中的红色印章
static double AdjustImageByGrayImage(cv::Mat &image, const cv::Mat &gray_image, uchar bg_gray_value, const std::vector< uchar > &thresholds)
通过灰度图像调整输入图像
cv::Size Size() const
获取图像的大小
Image & HorizontalLengthSmooth(int threshold)
水平游程平滑
virtual cv::Mat Preprocess(const cv::Mat &image) const
预处理图像
const Lines & ClassifyLines(Lines &hlines, Lines &vlines) const
对线段进行分类
List< T > Filter(const FUNC &func) const
过滤列表项
#define Cm_Assert(expr, message)
断言宏
std::string Sprintf(const char *format,...)
格式化输出字符串
@ HLINE
横线 (horizontal line)
@ ULINE
未知线类型 (unknown line)
@ VLINE
竖线 (vertical line)
@ RT_AUTO
自动调整大小,支持放大和缩小图片
unsigned char uchar
无符号字符类型
SeparatedColorType
支持分离的颜色类型枚举