Giter VIP home page Giter VIP logo

mirrorsymmetry's Introduction

Detecting Mirror Symmetry

Introduction

Bilateral Symmetry is renamed as mirror symmetry. In this project, I will write a computer program to detect mirror symmetry objects within the given image, and add mirrors line according to the algorithm in paper Detecting Symmetry and Symmetric Constellations of Features by Loy and Eklundh.

At a high level, the program compares the feature points on the image to those on the reflected version of the image, and then draws mirror lines based on the dominating symmetry pairs.

Usage

You need OpenCV, Matplotlib, and NumPy to run the script

python detect.py example # show an example with details
python detect.py test  # show other test cases

Detecting Steps:

The approach is based on the simple idea of matching symmetric pairs of feature points.

The approach is based on the simple idea of matching symmetric pairs of feature points. You can find the following steps in detecting_mirrorLine function in mirror_symmetry.py.

  1. Translate image and its reflective version into numerical array/matrix (i.e. a collection of points with row and column index)

  2. Extract key features:

    • Find the key points (some sort of distinctive point) and descriptors with SIFT (a feature detection algorithm provided in OpenCV library). Each feature can be represented by a point vector describing its location in x, y coordinates, and its orientation.
  3. Matching pairs of features:

    • Using BFMatcher (feature matching method provided in OpenCV) to match pairs of symmetry key points between original image and its reflective version. Then generates a collection of matched pairs of feature points called matchpoints, which is sorted by the distance between each pair of descriptors. The lower the distance, the better the symmetry match.
    • Normalise orientation of mirror feature: Convert angles from degrees to radians (๐…*radians = 180 degrees) within [0,2๐…].
    • Symmetry of each pair of points then is computed directly with (r, ฮธ) values (polar coordinates).
  4. Finally Draw mirror lines based on the highest 'votes' from the result of the hexbin plot (the highest count of (r, ฮธ)), which represents a line in polar coordinates.

Performance

Butterfly Example

The left figure shows the top 10 pairs of mirror symmetry points. The yellow point of the middle plot is (6.18 , 2,42) (the (r, ฮธ) values with the highest votes), which is the mirror line in polar coordinates (see right figure).

Test case

Animals, human and architecture

The testing results of symmetry animal and human face, and symmetry architecture looks good.

Symmetry object with shadow, reflection and rotational Symmetry

My current algorithm cannot draw mirror line correctly for the symmetry object with shadow (left image). And it cannot identify the reflection of object. See the middle image, the correct mirror line should be horizontal between the mountain and its reflection. Also, it draws a random line on the rotational symmetry object (right image).

Multiple symmetry object within one image

If the input image contains more than one symmetry object, my code can identify one of mirror symmetry object (left image), or fail to identify any one of them(right image).

See more test cases in Detect_SymmetryPattern.ipynb.

mirrorsymmetry's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.