Meaning of the seven Hu invariant moments function from OpenCV

前端 未结 2 546
没有蜡笔的小新
没有蜡笔的小新 2021-01-31 10:59

I understand that the seven hu invariant moments are for translation, rotation, and scale change of the object, in order to recognize the object independently these factors.

2条回答
  •  时光说笑
    2021-01-31 11:31

    To answer your second question:

    I don't think the invariant moments have any meaning. They're simply guaranteed to be constant for a given shape, no matter how it's shifted, rotated, or scaled.

    The kind of meaning you sound like you'd like to know about them:

    what data is related to rotation, what for translation and what for scale change?

    doesn't quite make sense since by definition, they are all not related to rotation, translation, and scale. However, once could easily ask a similar question but for other properties, for example:

    what data is related number of corners, roundness, or width to height ratio?

    Here I think it's obvious that these moments don't relate to any arbitrary property one would like it to relate to so the answer again is there is no meaning.

    So where does that leave us? With this: if we want to compare two objects to tell if their "shape" is similar (and by "shape" we mean that we don't care about rotation, translation, and scale changes), we can calculate the hu invariant moments and compare them. If these values are "approximately" equal, then you can hopefully say that the shapes are "approximately" the same. One would then hope that these moments vary wildly between different shapes - and whether they do or not is an interesting question that maybe someone else can answer.

    For example, lets say we calculate some of the the moments (only showing three and with ranges 0 to 1 for simplicity) of a square as:

    (0.5, 0.5, 0.5)
    

    We would then hope that a circle gives something like:

    (0.5, 1, 0.5)
    

    And an oval:

    (0.5, 1, 0.7)
    

    This may allow you to compare these shapes. If you calculate the moments of an unknown shape and get:

    (0.51, 0.98, 0.47)
    

    it's probably (hopefully) a circle. If however a star gave you:

    (0.2, 0.6, 0.9)
    

    and a crescent also gave the same thing, that wouldn't be so useful. With seven moments though, there's quite a bit of potential for at least a few of the moments to vary significantly for what we may consider important features of a shape.

    Hope this helps.

提交回复
热议问题