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: 
I can find no wording in [n4296](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf) (draft C++14 standard) which would make this legal. What is more, I cannot *even* find any wording that given:

```
union Big2 {
    Hdr h;

    A a;
    B b;
    C c;
    D d;
    E e;
    F f;
};

```

we can `reinterpret_cast` a reference to `Big` into a reference to `Big2` and then use the reference. (Note that `Big` and `Big2` are *layout-compatible*.)
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)

```