Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将较小的图像放入较大的图像中。_C#_Opencv_Emgucv - Fatal编程技术网

C# 将较小的图像放入较大的图像中。

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

我需要把一个较小的图像放在一个较大的图像中。较小的图片应位于较大图片的中心。我正在与C#和OpenCV合作,有人知道如何做到这一点吗?

这对我很有用

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+的另一个示例。