You are here: Start » Program Examples » Bottle Flattening
Bottle Flattening
Aim
The aim of the program is to extract a cylindrical surface and transform it into 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 presenting a bottle can be flattened in several ways but the easiest one 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.
Solution (AVS)
- Add filter LoadImage.
 - Add filter CreateCylinderMap and connect outImage from the previous filter with inImageFormat.
 - In this filter you have to specify inCylinderRectangle input.
- Click on this input in Properties window.
 - Mark a rectangle on the surface to be flattened.
 - Click OK.

 
 - Set inCylinderRadiusCorrection in Properties window to 2.
 - The previous filter is not going to display the required result, so we have to use an additional filter RemapImage so you have to add it to the program.
 - Connect inImage with outImage from LoadImage and inSpatialMap with outSpatialMap from CreateCylinderMap.
 
Macrofilter Main

Used Filters
| Icon | Name | Description | 
|---|---|---|
| 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). | |
| CreateCylinderMap | Inspection of the surface of bottles and other cylindrical objects. The result is used by RemapImage. | 
Further Readings
- Image Processing - A comprehensive introduction to Image Processing.
 
