Resize ROI
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
-
Luca,What is the shape of the ROI (ellipse, rectangle, polygon)? If it's a polygon, you can adjust it dragging ROI handlers.Yuri0
-
-
It is a complex polygon, so my willing is to make it bigger constraining proportion (next comment will show an example of what i want to do):thanks a lotLuca0
-
Ok, I understand,what a pity…thank you very much for fast and clear answer!Luca0
-
Luca,There is a possible workaround but it involves multiple steps.
- Load the Feature Manager and add your ROI to it.
- Convert the ROI to an annotation in Feature manager.
- Apply the new annotation to an image.
- Create an annotation group (add one annotation if there is only one)
- Then you can re-scale the group using the Shift key.
- Convert the annotation back to a ROI and apply to your image.
Pierre0 -
Thanks you a lot Pierre!It is a very smart workaround, really!It happens to you to that when i try to re-scale the group using the Shift key it constrains the proportion but it also automatically before modify the group into a square-size group? Not easy to explain… but it helps a lot! Thank you again!0
-
The macro to scale all ROI polygons by 1.2 (“d” defines scaling factor).
0 -
Public Function ScaleAllROIPolygons() As SimpleScript
ScaleAllROIPolygons = New SimpleScript
Dim image1With Application.DocumentCommands.ActiveImage(ScaleAllROIPolygons)
.Run(image1)
End WithWith 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 Singleim = 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 WithEnd Function
0 -
Luca,Somehow you replaced "d" by 3.148, so instead ofDim d As Double = 1.2you haveDim 3.148 As Double = 1.2How could it happen? Try to paste the macro again.Yuri0
-
I understood that the d should be replaced by my converting factor (that is 3.148)should I put this number instead of 1.2?In any case, it doesn't work, it gives me this message:Unexpected text.Module 'Macros.vb', line 1, character 12.0
-
Thanks Nikita,it works almost well the unique problem is that together with the resizing, it goes out from the image field, so it is impossible to select it and it disappear when I select other objects. (see the screenshot).0
-
Hi Yuri, Hi Nikita, thanks a lot for the explication (after knowing how it works, having the ROI in the upper left part of the image also solve the problem) and the new one that works great as well!Now the problem is totally solved!Thanks!0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions