简体   繁体   中英

cut and paste a small image into a larger image in Emgu (a wrapper for Python)

I am trying to paste a small image Size(100, 100) into a larger image Size(500, 500) at a location point(10,10) in the larger image using emgu (a wrapper for Python) using vb.net/C#.

I've tried setting the larger images ROI to Rectangle(Point(10,0), Size(100, 100)) and then performing a CopyTo command. But the copyTo command simply overwrites the larger image (see code below)

In Python copying a small to a larger image at point(10,10) is easy. Something like this would work...

image_large[10:10, 110:110]= image_small[0:100, 0:100]

But how do I do this in Emgu?

        Dim image_small As New Image(Of Gray, Byte)(New Size(100, 100))
        Dim image_large As New Image(Of Gray, Byte)(New Size(500, 500))

        image_small.SetValue(New Gray(100))   'Gray
        image_large.SetValue(New Gray(0))     'Black

        image_large.ROI = New Rectangle(New Point(10, 10), New Size(100, 100))
        image_small.CopyTo(image_large)

这就是我所期待的

I got it. Its not intuitive though...

    Dim image_small As New Image(Of Gray, Byte)(New Size(100, 100))
    Dim image_large As New Image(Of Gray, Byte)(New Size(500, 500))

    image_small.SetValue(New Gray(100))   'Gray
    image_large.SetValue(New Gray(0))     'Black

    image_large.ROI = New Rectangle(New Point(10, 10), New Size(100, 100))

    'This assigns a 1 to each element in ROI which prepares it for next command
    image_large.SetValue(New Gray(1))

    'This multiplies the 1 by the elements in image_small
    image_large._Mul(image_small)

    image_large.ROI = Rectangle.Empty

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM