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)
CodePudding user response:
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