Morphology of binary images During the lecture we talked about analysis of pictures and got some exrecises. Other students say that this is very easy but I don't get a good answer. Here the facts:
Suppose $A$ is a bounded subset of $\Bbb{Z}^2$ (the image) and $B\subset\Bbb{Z}^2$ a structureing element (for example $B_1=\{z\in\Bbb{Z}:|z_1|\leq1,|z_2|\leq1\}$ thus a square). Now define the following operations:


*

*Erosion: $A-B=\{z\in A:z+B\subset A\}$

*Dilation: $A+B=\{z\in\Bbb{Z^2}:z+B\cap A\neq \emptyset\}$

*Opening: $A\circ B=(A-B)+B$

*Closing: $A\bullet B=(A+B)-B$


Now we should prove the following three facts:


*

*$A-B\subset A\circ B\subset A\subset A\bullet B\subset A+B$ (from my point of view this fact is very simple and there is nothing to prove but how to do this on the best way because you get some strange sets)

*$(A\circ B)\circ B=A\circ B$ and $(A\bullet B)\bullet B=A\bullet B$ (one inclusion is per definition always trivial but the other side?)

*Suppose $p\in A$. Define $X_1=\{p\}$ and $X_{k+1}=X_k+B_1$ (with $B_1$ the square defined above). Show that $X_k$ converges in finitely many steps to the connected component of $A$ containing $p$ (sorry, i have no idea ...)


Image analysis is very interesting, please help me to understand all facts of this topic :)
Thank you for help and ideas.
 A: I think, because of the nature of the problem, we can assume $(0,0)\in B$. That $B\ne\emptyset$, is needed because otherwise $A+B=\emptyset$ would hold. Moreover, I found that,
for proving $A\circ B\subseteq A$, we also need that $B$ is symmetric, that is $b\in B\Rightarrow -b\in B$. (We can construct simple $1$ dimensional counterexample for other cases: e.g. let $B=\{0,1\}$ and $A:=\{-1,0,1\}$ on $\Bbb Z$.)
Then,  observe that $A-B\subseteq A$ (by definition) and, by the hypothesis $(0,0)\in B$, we also have $A+B\supseteq A$ as $z\in z+B$ which intersects $A$ whenever $z\in A$.


*

*So, we have $A-B\subseteq (A-B)+B=A\circ B$.

*Let $z\in A\circ B=(A-B)+B$, then we have $z+b\in A-B$ for some $b\in B$, meaning $z+b+B\subseteq A$. By symmetry of $B$, we have $-b\in B$, so $z\in A$ follows.

*Let $z\in A$, then, again by symmetry, $z+B\subseteq A+B$, because with any $b\in B$, we have that $z+b+B$ intersects $A$, using $-b\in B$. So, we have $A\subseteq (A+B)-B=A\bullet B$.

*$A\bullet B=(A+B)-B\subseteq A+B$.

*By the above ones, $(A\circ B)\circ B\subseteq A\circ B$ and $A\bullet B\subseteq (A\bullet B)\bullet B$ follows. For the converse, I suggest to rephrase the definition of $A\circ B$ and $A\bullet B$ as follows:
$$A\circ B=\{z \mid \exists b\in B: z+b\in A-B\}=\\ =
\{ z \mid \exists b\in B: z+b+B\subseteq A \} \\
A\bullet B=\{z \mid \forall b\in B: z+b\in A+B\}=\\ =
\{ z \mid \forall b\in B: (z+b+B)\cap A \ne\emptyset \} .$$
In case you have any problems with it, let me know.

*The convergence statement, as it is, is simply false, because the procedure is totally independent from $A$, that is, for different $A$ sets (sharing the same $p$ point to start) we will have exactly the same sequence of $X_k$'s.
It was most probably meant like
$$X_{k+1}:=(X_k+B_1)\cap A$$
then it makes sense. For the proof, consider two cases for a generic point $z\in A$: 1) $z$ is in the same component as $A$ (because of the shape of $B_1$, diagonal connection of pixels is now valid as connection), and 2) $z$ is in a different connected component.

