You are here: Start » Program Examples » Bottle Flattening
Bottle Flattening
Aim:
The goal of this example is to transform a cylindrical surface to a flat rectangle.
Input:
The image of a bottle with a label on a cylindrical surface.
Output:
A flattened part of the image showing the label.
Hints:
An image of a bottle can be flattened in several ways, but the easiest method is to think of the bottle as a cylinder and consider one of the Image Spatial Transforms Maps filters to create a proper map and then display it as an image.
Labeling connections is explained in this article.
You can learn how to enable sections here.
Solution (FIS):
- Add the filter CreateCylinderMap to the INITIALIZE section and set inImageFormat parameters as follows:
- Width: 2058
- Height: 2456
- Type: UInt8
- Depth: 1
- PitchAlignment: 16
2. In this filter, you have to specify the inCylinderRectangle input.
* Click on this input in Properties window.
* Mark a rectangle on the surface to be flattened.
* Click OK.
3. Set inCylinderRadiusCorrection in the Properties window to 2. This parameter describes how many pixels the cylinder radius is larger than the visible circle radius.
4. The previous filter created a spatial map for transformations from the cylinder surface to the flat rectangle. To apply the computed image transform, defined by the spatial map,
a RemapImage filter needs to be used.
5. Add the filter LoadImage to the ACQUIRE section.
6. Add the RemapImage filter to the program, connect inImage with outImage of the LoadImage filter and inSpatialMap with outSpatialMap of the CreateCylinderMap.
Macrofilter Main
Used Filters
Icon | Name | Description |
---|---|---|
![]() |
CreateCylinderMap | Inspection of the surface of bottles and other cylindrical objects. The result is used by RemapImage. |
![]() |
LoadImage | Loads a single image from a file. |
![]() |
RemapImage | Fast (precomputed) image transformations, especially for view undistortion or object geometry correction (e.g. pos recognition of labels on cylindrical bottles). |
Further Readings
- Image Processing - A comprehensive introduction to Image Processing.