Resize ROI
Hi,
I have a problem with managing the ROI in Image Pro Premiere 9.1;
I have to transfer a ROI between two similar image of different size. I can copy the ROI from the first to the second image, I can rotate it, but I can't resize it in order to fit it in a larger image.
How can I do?
Best Reagards
Luca Ferrantino
0
Best Answers
-
Hi Luca,I see what you want to do, but scaling of polygons is not supported in the UI, you can only adjust locations of handles. (scaling can be done using a macro).The easiest way would be to resize the image (either increase the size of original template image or decrease the size of the target image). In that case you don't have to resize ROI.Yuri0
-
Hi Luca,
I’ve attached the project package (ScaleAllROIPolygons.ipx) for easy use. Add this project and run ScaleAllROIPolygons macro. The macro will prompt for the scaling factor and scale all ROIs polygons on the active image.
0 -
This macro scales ROI by multiplying XY coordinates by the scaling factor of polygon’s points. This way keeps relative position of the polygon then transferring from the small to big image.0
-
Hi Luca,I've slightly modified Nikita's project (attached), so the ROI is scaled relative to it's center. Hopefully it's what you need.Yuri0
Answers
The macro to scale all ROI polygons by 1.2 (“d” defines scaling factor).
Public Function ScaleAllROIPolygons() As SimpleScript
ScaleAllROIPolygons = New SimpleScript
Dim image1
With Application.DocumentCommands.ActiveImage(ScaleAllROIPolygons)
.Run(image1)
End With
With Automate.ScriptingCommands.CodeCommand(ScaleAllROIPolygons)
If .Run() Then
' User Code Here
Dim d As Double = 1.2
Dim im As MediaCy.IQL.Engine.McImage
Dim roi As MediaCy.IQL.Features.McRegions
Dim ovl As MediaCy.IQL.Display.Overlays.McGraphOverlay
Dim x As Single, y As Single
im = TryCast(image1, MediaCy.IQL.Engine.McImage)
If im IsNot Nothing Then
roi = im.Aoi
ovl = roi.AutoDisplayOverlay
ovl.SetEnumFilter(MediaCy.IQL.Display.Overlays.mcGraphOverlayEnumWhat.mcgewMaster,"McGraphObjPoly")
For Each poly As MediaCy.IQL.Display.Overlays.McGraphObjPoly In ovl
For i As Integer = 1 To poly.PointCount
poly.GetHandle(i, x, y)
x = d * x
y = d * y
poly.SetHandle(i, x, y)
Next
Next
End If
End If
End With
End Function