C# 将较小的图像放入较大的图像中。
我需要把一个较小的图像放在一个较大的图像中。较小的图片应位于较大图片的中心。我正在与C#和OpenCV合作,有人知道如何做到这一点吗?这对我很有用C# 将较小的图像放入较大的图像中。,c#,opencv,emgucv,C#,Opencv,Emgucv,我需要把一个较小的图像放在一个较大的图像中。较小的图片应位于较大图片的中心。我正在与C#和OpenCV合作,有人知道如何做到这一点吗?这对我很有用 LargeImage.ROI = SearchArea; // a rectangle SmallImage.CopyTo(LargeImage); LargeImage.ROI = Rectangle.Empty; EmguCV当然这对我很有效 LargeImage.ROI = SearchArea; // a rectangle SmallIm
LargeImage.ROI = SearchArea; // a rectangle
SmallImage.CopyTo(LargeImage);
LargeImage.ROI = Rectangle.Empty;
EmguCV当然这对我很有效
LargeImage.ROI = SearchArea; // a rectangle
SmallImage.CopyTo(LargeImage);
LargeImage.ROI = Rectangle.Empty;
当然,上面的答案很好!下面是将水印添加到右下角的完整方法
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;
}
公共静态图像水印(图像img,图像水印)
{
矩形矩形;
//矩形应具有与水印相同的比率
if(img.Width/img.Height>waterMark.Width/waterMark.Height)
{
//根据宽度调整大小
内部宽度=内部宽度/10;
int height=width*waterMark.height/waterMark.width;
int left=img.Width-宽度;
int top=仪表高度-高度;
rect=新矩形(左、上、宽、高);
}
其他的
{
//根据高度调整大小
内部高度=内部高度/10;
int width=height*waterMark.width/waterMark.height;
int left=img.Width-宽度;
int top=仪表高度-高度;
rect=新矩形(左、上、宽、高);
}
水印=水印.Resize(rect.Width,rect.Height,Emgu.CV.CvEnum.INTER.CV\u INTER\u区域);
img.ROI=rect;
带水印的图像=img.Add(水印);
withWaterMark.CopyTo(img);
img.ROI=矩形。空;
返回img;
}
以上答案很好!下面是将水印添加到右下角的完整方法
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;
}
公共静态图像水印(图像img,图像水印)
{
矩形矩形;
//矩形应具有与水印相同的比率
if(img.Width/img.Height>waterMark.Width/waterMark.Height)
{
//根据宽度调整大小
内部宽度=内部宽度/10;
int height=width*waterMark.height/waterMark.width;
int left=img.Width-宽度;
int top=仪表高度-高度;
rect=新矩形(左、上、宽、高);
}
其他的
{
//根据高度调整大小
内部高度=内部高度/10;
int width=height*waterMark.width/waterMark.height;
int left=img.Width-宽度;
int top=仪表高度-高度;
rect=新矩形(左、上、宽、高);
}
水印=水印.Resize(rect.Width,rect.Height,Emgu.CV.CvEnum.INTER.CV\u INTER\u区域);
img.ROI=rect;
带水印的图像=img.Add(水印);
withWaterMark.CopyTo(img);
img.ROI=矩形。空;
返回img;
}
Krish没有。我正在使用OpenCV和C。你有什么办法帮我吗?有一个关于水印图像的网站可能会帮你。我认为这与你正在做的事情非常接近。另外,一定要在CodeProject上查看另一个使用GDI+.Krish not的示例。我正在使用OpenCV和C。你有什么办法帮我吗?有一个关于水印图像的网站可能会帮你。我认为这与你正在做的事情非常接近。另外,请务必在CodeProject上查看使用GDI+的另一个示例。