0

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)

This is what I was expecting

  • Did you try to reset the ROI to an empty rectangle in the end? Or not setting the ROI, but a `CopyTo()` overload that accepts `RowRange` and `ColRange` coordinates – Jimi Dec 24 '22 at 09:52
  • After the image_small.CopyTo(image_large) I did a image_large.ROI = Nothing and it didnt do anything. image_large wasn't changed. And there aren't RowRange and ColRange properties in Image(Of Gray, Byte). – Doug Schofield Dec 24 '22 at 21:36

1 Answers1

0

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