Algorithmic emoji style transfer
Transform an emoji into a given contour of another one
Initial source of the idea: OpenCV transform image shape transformation into a given contour
The core solution is to align points from one image contour to another one. But how to do it without manual operations? That was the main question I tried to solve. As a result, I wrote three methods to tackle the task:
- Contour points sampling, CPS
- Get images of the equal size
- Extract object mask
- Extract object contour
- Sample contour for each image
- Calculate distance matrix & perform linear sum alignment to get the proper points pairs
- Split images into triangles and perform affine transformations and warping to fit triangles to the primary image.
- Contour areas stratification, CASv1
- Get images of the equal size
- Extract object mask
- Extract object contour
- Extract bbox of a contour
- Find closest contour points to bbox vertices
- Split contour points based on closest vertices to areas: top, bottom, left, right. Combine sorted areas.
- Split images into triangles and perform affine transformations and warping to fit triangles to the primary image.
- Contour areas stratification v2, CASv2
- Get images of the equal size
- Extract object mask
- Extract object contour
- Get contour of a mask
- Get convex hull of the previously extracted contour
- Create a new mask from the resulting convex hull
- Get final contour from the new mask
- Extract bbox of a contour
- Find closest contour points to bbox vertices
- Split contour points based on closest vertices to areas: top, bottom, left, right. Combine sorted areas.
- Split images into triangles and perform affine transformations and warping to fit triangles to the primary image.
Examples: