我需要将较小的图像放在较大的图像中。较小的图片应该在较大的图片中居中。我正在使用 C# 和 OpenCV,有人知道该怎么做吗?
问问题
2777 次
2 回答
2
这对我有用
LargeImage.ROI = SearchArea; // a rectangle
SmallImage.CopyTo(LargeImage);
LargeImage.ROI = Rectangle.Empty;
当然是 EmguCV
于 2015-04-20T08:23:17.607 回答
0
楼上的回答太好了!下面是一个在右下角添加水印的完整方法。
public static Image<Bgr,Byte> drawWaterMark(Image<Bgr, Byte> img, Image<Bgr, Byte> waterMark)
{
Rectangle rect;
//rectangle should have the same ratio as the watermark
if (img.Width / img.Height > waterMark.Width / waterMark.Height)
{
//resize based on width
int width = img.Width / 10;
int height = width * waterMark.Height / waterMark.Width;
int left = img.Width - width;
int top = img.Height - height;
rect = new Rectangle(left, top, width, height);
}
else
{
//resize based on height
int height = img.Height / 10;
int width = height * waterMark.Width / waterMark.Height;
int left = img.Width - width;
int top = img.Height - height;
rect = new Rectangle(left, top, width, height);
}
waterMark = waterMark.Resize(rect.Width, rect.Height, Emgu.CV.CvEnum.INTER.CV_INTER_AREA);
img.ROI = rect;
Image<Bgr, Byte> withWaterMark = img.Add(waterMark);
withWaterMark.CopyTo(img);
img.ROI = Rectangle.Empty;
return img;
}
于 2015-07-03T21:58:42.073 回答