#include <iostream>
int morph_elem = 0;
int morph_size = 0;
int morph_operator = 0;
int const max_operator = 4;
int const max_elem = 2;
int const max_kernel_size = 21;
const char* window_name = "形态学变换演示";
void Morphology_Operations( int, void* );
int main(
int argc,
char** argv )
{
src = imread( samples::findFile( parser.get<
String>(
"@input" ) ), IMREAD_COLOR );
{
std::cout << "无法打开或找到图像!\n" << std::endl;
std::cout << "用法:" << argv[0] << " <输入图像>" << std::endl;
return EXIT_FAILURE;
}
namedWindow( window_name, WINDOW_AUTOSIZE );
createTrackbar("算子:\n 0:开运算 - 1:闭运算 \n 2:形态梯度 - 3:顶帽 \n 4:黑帽", window_name, &morph_operator, max_operator, Morphology_Operations );
createTrackbar( "结构元素:\n 0:矩形 - 1:十字形 - 2:椭圆形", window_name,
&morph_elem, max_elem,
Morphology_Operations );
createTrackbar( "核大小:\n 2n +1", window_name,
&morph_size, max_kernel_size,
Morphology_Operations );
Morphology_Operations( 0, 0 );
waitKey(0);
return 0;
}
void Morphology_Operations( int, void* )
{
int operation = morph_operator + 2;
}
用于命令行解析。
定义 utility.hpp:890
bool empty() const
如果数组没有元素,则返回true。
用于指定图像或矩形大小的模板类。
定义 types.hpp:335
std::string String
定义 cvstd.hpp:151
void imshow(const String &winname, InputArray mat)
在指定的窗口中显示图像。
void morphologyEx(InputArray src, OutputArray dst, int op, InputArray kernel, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar &borderValue=morphologyDefaultBorderValue())
执行高级形态学变换。
Mat getStructuringElement(int shape, Size ksize, Point anchor=Point(-1,-1))
返回用于形态学运算的指定大小和形状的结构元素。
int main(int argc, char *argv[])
定义 highgui_qt.cpp:3