Home Image-Pro General Discussions

XY coordinates of an outline

Hi. I need to extract the X and Y coordinates of the outline of my image for Elliptical Fourier analysis. How do I do this?

Answers

  • You can check the following post that shows how to extract outline coordinates: http://forums.mediacy.com/discussion/comment/543/

    If your are interested in the shape Fourier analysis, you may look at the build in Premier's Fourier Descriptor measurement. There are several posts on the forum that show how to use it:

    http://forums.mediacy.com/discussion/103/how-to-use-fourier-descriptor-for-object-shape-classification/p1

    http://forums.mediacy.com/discussion/103/how-to-use-fourier-descriptor-for-object-shape-classification/p1

    http://forums.mediacy.com/discussion/125/can-i-get-the-fourier-descriptor-coefficients-for-an-object-outline-without-using-macro-code/p1

    You can also find more info on Fourier Descriptor in the Image-Pro Premier Automation Help.

    Regards,

    Yuri
  • Hi Yuri. Thanks for the speedy response. Like the previous poster I am not familiar with macros and cannot seem to download the "attached project" that you mention in that post. Can you please send it again? I am aware that you can run Fourier analysis in Premier but I will likely run the EFDs in R. 

    Thanks,

    Eimear
  • Hi Eimear,

    Here is the project. Use PrintOutlineCoordinates to print coordinates to the output window.

    Yuri
  • Hi Yuri. Thanks for that. I haven't a clue how to use it or what it really does but I'll give it a shot. You may be hearing fro me in the very near future :)
  • Hi Yuri. Wow pretty straight forward except I have a few questions.
    1. When the data points are plotted around the outline there are some gaps where no data point is picked up why is this?
    2. How do I manipulate how the xy coordinates are exported to excel? I want the data as two columns, x  and y as opposed to a single row.
    3. Can I apply a smoothing factor during the process, the pixel connectivity value is used was 8?

    Thanks
  • 1. Outline points are coordinates on straight line segments, so if you have straight edge, only a point at the beginning and the end of the line is included into outline. There is another macro in that project ConvertToEvenDistancePoints that will place points on the same interval along the outline. The default number of points is 15, but you can increaseit if necessary modifying the value on line 52.
    2. You can change the output format of the coordinates on line 40. Use this code to print it into 2 columns:

                s+=vbCrLf
                For Each p As SINGLEPOINT In points
                    s+=p.x.ToString("F2") & vbTab & p.y.ToString("F2") & vbCrLf
                Next

    3. You can apply smoothing during Count, use Smoothing parameter in the Segmentation options group of the Measurement options panel.

    Yuri
  • Hi Yuri. Thanks for all that. Another question I need the outline coordinates to always start at a standard location, is there a way to do this?

    Eimear
  • Hi Eimear,

    Outlines created by Count start from the left pixel on the top line of the object and go clockwise. Outlines are circular arrays and if you need different "standard location" then you should find the index of the point closest to that location and start from there.
    You can also rotate the image, so the "standard location" will be on the top and count again.

    BTW, shape normalization by size, orientation and outline starting point is implemented in Fourier Descriptor, so you may check again the demo project (macro DemoFourierDescriptor) to see how it works:

    http://forums.mediacy.com/discussion/103/how-to-use-fourier-descriptor-for-object-shape-classification/p1

    Check the code starting from line 71 in Module2.vb, it creates normalized object outline:

        'Step 1
        'normalize object size and orientation and display normalized object's outlines
        'do not normalize the translation to show the outlines obove the objects
        rg.maRgnFourierDescriptor.NormalizeFlags=mcfdNormalizeFlags.mcfdNormalizeRotation Or  mcfdNormalizeFlags.mcfdNormalizeScale
    
        For i = 0 To rg.Count - 1
            'get normalized Fourier Descriptor
            vFourierDescr = rg.maRgnFourierDescriptor.Value(i)
            'apply inverse FFT transform to Fourier Descriptor to get normalized object outline
            ThisApplication.ActiveImage.fft.Inverse1D(vFourierDescr, vdInverted, MediaCy.IQL.Filters.mcFFTForwardOutput.mcfoRealImaginaryDouble)
            'draw outline defined by descriptor
            DrawBoundary( ThisApplication.ActiveImage, vdInverted)
        Next i
    
        MsgBox ("Normalized object outlines are shown on the image." & vbCrLf & "Note that outlines of similar objects have the same size, " & vbCrLf & "orientation and starting point.", vbInformation, "Fourier Descriptor")
    

    Yuri
Sign In or Register to comment.