higra / Higra

Hierarchical Graph Analysis
Other
97 stars 20 forks source link

`correct_attribute_BPT` #255

Closed ShoufaChen closed 1 year ago

ShoufaChen commented 1 year ago

Hi,

Thanks for your awesome work.

I am confused by the following code:

https://github.com/higra/Higra/blob/314a358f670f4fd291a65a5f565860ef60ff0a71/include/higra/hierarchy/watershed_hierarchy.hpp#L24-L47

Could you give me some hints about the purpose of these steps?

Thanks in advance.

PerretB commented 1 year ago

Hello,

this function is here to handle cases where more than 2 neighboring minima merge at the same altitude. Consider the following case (Fig 3 of https://hal.archives-ouvertes.fr/hal-00798621/document ) where we consider an area attribute:

image

The nodes n1, n2 and n3 represent three minima, of respective sizes 2, 3 and 6, that are linked by edges of weight 1. Then the node n6 represent the merge of n1 and n2, its "true" area is 2+3 = 5. The node n7 is the merge of n6 and n3, its "true" area is 5 + 6 = 11.

Now, what we want is not the "true" area of the nodes: we want to know at which area filter size, the minima below a given node will disappear. The minima below n6 both disappear if we remove the components of area <= 3 = max(2,3). However, the situation is different for n7 which will still contain a minimum up to a filtering size of 11 = 5 + 6. We can differentiate those two situations by looking at the altitude of the current node and its parent: if the altitude is the same, we are in the first case, if they are different, it's the second case.

So the correct_attribute_BPT function takes as input a "real" attribute and deduce the "persistence" of the minima below a node for this attribute.

I hope this helps, this part is only very briefly described in the article mentioned above and as an internal function of the library it is even worse here :)

PeizeSun commented 1 year ago

@PerretB Hi, Thanks for your great work.

Could you give more explanation about "the situation is different for n7 which will still contain a minimum up to a filtering size of 11 = 5 + 6. " ? I am confused why area <= 6 = max(5,6) doesn't work for n7 ? Why different altitudes of the current node and its parent could differentiate those two situations ?

Thanks very much.

PerretB commented 1 year ago

In the case of n6, as its parent n7 has the same altitude, there isn't any "real" component with an area of 5. If we remove the components of area <= 3 we get this (sorry crappy figure editing, right part of the figure ignored):

image

There is no more minimum under n6, just a plateau that is part of the regional minimum represented by n3.

While in the case of n7, there is actually a component of area 11 in the signal. If we remove the components of area <= 6 we get this:

image

And there is a still a minimum of area 11 below n7.

ShoufaChen commented 1 year ago

Hi, @PerretB

Thanks very much for your illustration.

We have got a better understanding from your explanation.

However, we don't know why chose area <= 3 = max(2,3) for the first situation, i.e., why not min or mean?

Besides, what's the purpose of the following accumulate_parallel (by min)?

https://github.com/higra/Higra/blob/314a358f670f4fd291a65a5f565860ef60ff0a71/include/higra/hierarchy/watershed_hierarchy.hpp#L88

PerretB commented 1 year ago

However, we don't know why chose area <= 3 = max(2,3) for the first situation, i.e., why not min or mean?

I suggest that you try making figures as I did : what happens if your remove components of area <= min(2,3) =2 or mean(2,3) = 2.5 ?

Besides, what's the purpose of the following accumulate_parallel (by min)?

For this you should refer to the paper Constructive links between some morphological hierarchies on edge-weighted graphs, in particular Section 7, Hierarchies of minimum spanning forests explains the definition of extinction and persistence values and their link with hierarchical watersheds.