how can a rect list be constructed using Premiere?
'I am trying to formulate an array of rectangles to use as ROI's later in another process. I am unable to find the rect variable type in premiere. what do I have to do? -thanks.
Public Sub Get_Rects()
Dim i,j As Integer
Dim rows As Integer = 11
Dim columns As Integer = 14
Dim wellwidth As Double = 218
Dim wellheight As Double = 222
Dim wellStartX As Double = 23
Dim wellStartY As Double = 286
Dim L, R, T, B As Double
'Dim myRect as rect
'Dim WellRect(154) As Rect
'Dim WellRect(154) As McRegions?
Dim counter As Integer = 0
For i = 0 To rows-1
L = wellStartX + (i*wellwidth)
R = L + wellwidth
'myrect.left = L
'myrect.right = R
For j = 0 To columns-1
T = wellStartY + (j*wellheight)
B = T + wellheight
'myrect.top = T
'myrect.bottom = B
'WellRect(counter)=myRect
'WellRect(counter) = ?
Next j
Next i
End Sub
0
Best Answer
-
Hi thans,
First function returns list of ROIs, the second draws ROIs on the active image:Public Function Get_Well_ROIs As System.Collections.Generic.List(Of System.Drawing.RectangleF) Dim ROIs As New System.Collections.Generic.List(Of System.Drawing.RectangleF) Dim i,j As Integer Dim rows As Integer = 11 Dim columns As Integer = 14 Dim wellwidth As Double = 218 Dim wellheight As Double = 222 Dim wellStartX As Double = 23 Dim wellStartY As Double = 286 Dim l, R, T, B As Double For i = 0 To rows-1 l = wellStartX + (i*wellwidth) R = l + wellwidth For j = 0 To columns-1 T = wellStartY + (j*wellheight) B = T + wellheight ROIs.Add(System.Drawing.RectangleF.FromLTRB(l,T,R,B)) Next j Next i Return ROIs End Function Public Function Well_ROIs() As SimpleScript Well_ROIs = New SimpleScript Dim doc1 With Application.DocumentCommands.Active(Well_ROIs) .Run(doc1) End With With [Select].RoiCommands.DeleteAll(Well_ROIs) .Run(doc1) End With With Automate.ScriptingCommands.CodeCommand(Well_ROIs) If .Run() Then ' User Code Here Dim ROIs As System.Collections.Generic.List(Of System.Drawing.RectangleF) Dim R As System.Drawing.RectangleF ROIs = Get_Well_ROIs For Each R In ROIs With [Select].RoiCommands.Add(Well_ROIs) .Points = New System.Collections.Generic.List(Of System.Drawing.PointF) .Points.Add(New System.Drawing.PointF(R.Left,R.Top)) .Points.Add(New System.Drawing.PointF(R.Right,R.Bottom)) .Angle = 0R .ROIType = Features.ROI.ROITypes.Rectangle .Run(doc1) End With Next End If End With End Function Thanks, Nikita.
0
Answers
I've modified your macro for Premier:
Public Function Well_ROIs() As SimpleScript Well_ROIs = New SimpleScript Dim doc1 With Application.DocumentCommands.Active(Well_ROIs) .Run(doc1) End With With [Select].RoiCommands.DeleteAll(Well_ROIs) .Run(doc1) End With With Automate.ScriptingCommands.CodeCommand(Well_ROIs) If .Run() Then ' User Code Here Dim i,j As Integer Dim rows As Integer = 11 Dim columns As Integer = 14 Dim wellwidth As Double = 218 Dim wellheight As Double = 222 Dim wellStartX As Double = 23 Dim wellStartY As Double = 286 Dim L, R, T, B As Double Dim counter As Integer = 0 For i = 0 To rows-1 L = wellStartX + (i*wellwidth) R = L + wellwidth For j = 0 To columns-1 T = wellStartY + (j*wellheight) B = T + wellheight With [Select].RoiCommands.Add(Well_ROIs) .Points = New System.Collections.Generic.List(Of System.Drawing.PointF) .Points.Add(New System.Drawing.PointF(L,T)) .Points.Add(New System.Drawing.PointF(R,B)) .Angle = 0R .ROIType = Features.ROI.ROITypes.Rectangle .Run(doc1) End With Next j Next i End If End With End Function Thanks, Nikita.