Question: Let's assume I have 2 matrices, which are representing a signalling with 1 and 0 in a 2D space.

```
A = [1,1,0,0;1,1,0,0;1,1,0,0];
A =

 1     1     0     0
 1     1     0     0
 1     1     0     0

B = [1,0,1,1;1,0,0,1;1,0,0,0];
B =
 1     0     1     1
 1     0     0     1
 1     0     0     0

```

Matrix A seems to cluster the signal, while matrix B is more random distributed. My goal is to identify noise with this approach in images, which should be much less structured than real signal.

Is there `regionprops` function which can do that? Any other suggestions?

My approach so far:

* Measure distances between the positive patches (get average)
* Use `bwareafilt` to detect the biggest patch.

Answer: 
This is UB by omission. [expr.ref]/4.2:

> 
> If E2 is a non-static data member and the type of E1 is “`cq1 vq1 X`”,
>  and the type of E2 is “`cq2 vq2 T`”, the expression [`E1.E2`] designates the
>  named member of the object designated by the first expression.
> 
> 
> 

During the evaluation of the `given_b_or_c` call in `given_big`, the object expression in `little.h` does not actually designate a `Little` object, and ergo there's no such member. Because the standard "omits any explicit definition of behavior" for this case, the behavior is undefined.
I'm not sure, if this really applies here. In the [`reinterpret_cast` - Notes](http://en.cppreference.com/w/cpp/language/reinterpret_cast#Notes) section they talk about pointer-interconvertible objects.

And from [[basic.compound]/4](http://eel.is/c++draft/basic#compound-4):

> 
> Two objects *a* and *b* are *pointer-interconvertible* if:
> 
> 
> * they are the same object, or
> * one is a union object and the other is a non-static data member of that object, or
> * one is a standard-layout class object and the other is the first non-static data member of that object, or, if the object has no non-static data members, the first base class subobject of that object, or
> * there exists an object *c* such that *a* and *c* are pointer-interconvertible, and *c* and *b* are pointer-interconvertible.
> 
> 
> If two objects are pointer-interconvertible, then they have the same address, and it is possible to obtain a pointer to one from a pointer to the other via a `reinterpret_­cast`.
> 
> 
> 

In this case, we have `Hdr h;` (c) as a non-static data member in both unions, which should allow to (because of the second and last bullet point)

```
Big* (a) -> Hdr* (c) -> Little* (b)

```