Home Image-Pro General Discussions
Options

How can I use the same ROI on multiple images?

I have a need to create a calibrated circle of a known diameter, and apply it to multiple images.  However, ROIs are specific to individual images and none of these images have the same dimensions.  If I do attempt to apply an ROI to an image other than the one in which it was created, it will be truncated.  How can I draw a circular ROI and save it for future use with all of my images?  Parenthetically, I note there is a feature for rectangles where the user can specify a fixed size.  it would be useful to add that for circles/ellipses in future releases.

Thanks!

Best Answer

  • Options
    edited June 2014 Answer ✓
    Hello,

    One way to accomplish this would be to use a macro. Here is a very basic one that will prompt for the calibrated circle center and diameter and create a ROI accordingly.

    Pierre

        Public Sub CreateCircularRoi()
            Dim image As McImage
            Dim circleValues(3) As Single
    
            With Application.DocumentCommands.ActiveImage(Nothing)
                .Run(image)
            End With
    
            Try
                Dim circleString As String = InputBox("Enter circle center and diameter:","ROI Creation","100 100 50")
                Dim values = circleString.Split(New String() {" "}, System.StringSplitOptions.RemoveEmptyEntries)
                circleValues(0) = values(0)
                circleValues(1) = values(1)
                circleValues(2) = values(2)
                circleValues(3) = values(2)
                image.SpatialCalibration.UnCalibrateFloatPoints(circleValues)
            Catch
                Exit Sub
            End Try
    
            With Select.RoiCommands.Add(Nothing)
                .Points = New System.Collections.Generic.List(Of System.Drawing.PointF)
                .Points.Add(New System.Drawing.PointF(circleValues(0),circleValues(1)))
                .Points.Add(New System.Drawing.PointF(circleValues(2),circleValues(2)))
                .ROIType = Features.ROI.ROITypes.Circle
                .Run(image)
            End With
        End Sub
    

Answers

  • Options
    I was hoping not to have to resort to a macro!  Thanks for the response; I do appreciate it!
Sign In or Register to comment.