You are here: Start » Program Examples » Cap Inspection 3D

Cap Inspection 3D

Aim

The aim of this example is to show 3D and 2D interoperability. The task is to segment caps, check their medium height and radius.

Input

Surfaces of caps grabbed by a 3D scanner.

Output

Image of segmented caps and their dimensions.

Hints

Having acquired point clouds of the Surface data type, try to find a filter which would enable you to convert them into images. Then you could use Region Analysis technique to perform segmentation. After extracting blobs representing caps you can analyze each one separately with SurfaceMedian and FitCircleToEdges3D. Labeling connections is explained in this article.

Solution (AVS)

  1. In Workspace Explorer open workspace Examples and in Film strip window select Cap3D dataset. Drag the Surface channel to the ACQUIRE section. Label the outSurface output as Surface.

  2. Add the CreateImageFromSurface filter to create an image of z-values of the given surface. It allows us to work with 2D tools, even though input data is 3D. Connect the Surface to the inSurface. Click on the filter and in the Properties window and set the inPixelType to UInt16. Set the inPixelScale to 0.010.

  3. Add the ExtractBlobs_Intensity to separate caps. Connect it with the outImage output of the CreateImageFromSurface. Set the inThresholdParams Polarity to Bright and the inProcessingParams MinArea to 500. Label the outBlobs output as CapRegions. Show the found blobs on a new preview window.

  4. Create a new step macrofilter, name it InspectSingleCap and connect following inputs to it:

  5. Go inside the InspectSingleCap step, label the inCapRegion input as CapRegion and the inSurface as Surface*.

  6. Add the AlignRegionToSurfaceFormat to transform each region defined in the 2D space into its 3D equivalent:

    • Connect the inRegion input to the CapRegion.
    • Connect the inInputSurfaceCoordinatesFormat the step's inSurfaceCoordinatesFormat input.
    • Connect the inOutputSurfaceFormat to the Surface.
  7. Add the SurfaceMedian to check the median height of each cap:

    • Connect the inSurface input to the Surface.
    • Connect the inRegion input to the outAlignedRegion output from the AlignRegionToSurfaceFormat.
    • Label the outMedian output as CapMedianHeight and connect it to the InspectSingleCap macrofilter output as outMedianHeight.
  8. Add the RegionBoundingCircle to find the boundaries of each found cap on the 2D image. Connect its input to the CapRegion.

  9. Add the ImageCircleToSurfaceCoordinates filter to convert the found 2D boundaries to the 3D version:

    • Connect the inImageCircle input to the outBoundingCircle of the RegionBoundingCircle.
    • Connect the inSurfaceCoordinatesFormat to the macrofilter's inSurfaceCoordinatesFormat input.
  10. Add the FitCircleToEdges3D to find edges of the cap. Later, circle is fitted to the obtained points. This operation is performed directly on the point cloud:

    • Connect the inSurface input to the Surface.
    • Click on Show/Hide Ports at the bottom of the filter and check the Axis option in the inFittingField submenu. Connect it to the outSurfaceCircle output of the ImageCircleToSurfaceCoordinates.
    • Set the inEdgeScanParams EdgeTransition to ValidToInvalid
    • Label the outCircle as CapCircle3D and connect it to the macrofilter's outputs. Name the new output as outCircle3D.
  11. Return to the Main macrofilter. Label the outCircle3D output of the InspectSingleCap as CapCircle3D and the outMedianHeight as CapMedianHeight. Click on Show/Hide Ports at the bottom of the filter and check the Radius option in the CapCircle3D submenu. Label the new output as CapRadius.

    1. Show the CapMedianHeight and the CapRadius on a new preview window.

Macrofilter Main.

Macrofilter InspectSingleCap

Further Readings

  • Blob Analysis - Article presents detailed information about the Blob Analysis technique.
  • Formulas - Detailed information about using formulas.
  • Geometry 3D - List of filters useful in 3D geometry.
  • Surface - Filters performing operations on surfaces in Aurora Vision Studio.