网站建设捌金手指花总二六,鞍山网上制作网站,抚养网站建设,手机建立网站多少钱QT 插件化图像算法研究平台的功能在持续完善#xff0c;补充了一个人工选择图片区域的功能。
其中#xff0c;图片选择功能主要代码如下#xff1a;
QRect GLImageWidget::getSeleted()
{QRect ajust(0,0,0,0);if(image.isNull() || !hasSelection)return ajust;double w1…QT 插件化图像算法研究平台的功能在持续完善补充了一个人工选择图片区域的功能。
其中图片选择功能主要代码如下
QRect GLImageWidget::getSeleted()
{QRect ajust(0,0,0,0);if(image.isNull() || !hasSelection)return ajust;double w1.0* imageSize.width()/ adaptImageSize.width();double h1.0* imageSize.height()/ adaptImageSize.height();ajust.setLeft((selection.left()-leftPos)*w/scaleVal);ajust.setWidth(selection.width()*w/scaleVal);ajust.setTop((selection.top()-topPos)*h/scaleVal);ajust.setHeight(selection.height()*h/scaleVal);return ajust;
}
需要考虑因素图片原始大小、窗口大小、图片显示在窗口的大小、图片在窗口的移动位置、图片在窗口的缩放、用户在窗口上框选的矩阵。
手工选择图片区域去水印 效果如下左上角人工框选处的文字给去除了。 主要代码参考如下
void deWaterMarkSelection(Mat input,Mat output,Mat src,string)
{auto selectRect processWinGetSelection();if(selectRect.width()0){outputinput;return;}Mat mask Mat::zeros(input.size(), CV_8U);auto topLeftselectRect.topLeft();auto bottomRightselectRect.bottomRight();Point rookPoints[1][4];rookPoints[0][0] Point(topLeft.x(),topLeft.y());//左上角rookPoints[0][1] Point(bottomRight.x(),topLeft.y());//右上角rookPoints[0][2] Point(bottomRight.x(),bottomRight.y());//右下角rookPoints[0][3] Point(topLeft.x(),bottomRight.y());//左下角int npt[]{4};//二维数组 每列长度const Point* ppt[1] {rookPoints[0]};//所有多边形点坐标fillPoly(mask, ppt, npt, 1, Scalar::all(255));//使用inpaint进行图像修复Mat result;inpaint(src, mask, output, 1, INPAINT_NS);
}