I'm looking at implementing an algorithm described in a paper, but I'm having trouble understanding how the transition probabilities for a Hidden Markov Model are defined.
In the first sections, I have segmented an image into a number of areas, each denoted as "text" or "gap". The algorithm then uses a HMM to refine these regions, and I'm stuck in the section of the paper that describes the parameters for the HMM.
It starts out easy enough by defining two states (c0 = text, c1 = gap) and their initial probabilities π0, π1 both being 0.5, but then the transition probabilities are described and there's something I'm missing. It goes:
"The transition probabilities are modeled by an exponential distribution with parameters mj, j ∈ {0,1}, the mean height of each region for the whole document image, as follows
ajj(i) = P(s[h,h+Hi] = cj | s[h-Hi-1,h] = cj)
= exp(-Hi/mj), j ∈ {0,1}
where Hi denotes the height of the i-th area and s[h,h+Hi] the state of the region that starts at height h and extends up to h+Hi. The transition probabilities of a01(i) and a10(i) result as the difference of a00(i) and a11(i) from 1, respectively."
From Papavassiliou, Stafylakis, Katsouros, Carayannis: "Handwritten document image segmentation into text lines and words" (Pattern Recognition 43 (2010) pp. 369-377)
I can easily do the exp() calculations with the area data that I have, but I don't understand how this becomes a 2x2 matrix. As I understand the formula, the result is dependent on the two variables i (= area index), and j (= 1 or 0) but how do I select i / the area it describes?
Update: Additionally, the regions are alternately text or gap; so the P() formula above should equal 0.0, as there are no two regions i, i-1 that have the same state. This would give a transition probabily matrix of:
$\begin{bmatrix} 0.0 & 1.0 \\ 1.0 & 0.0 \end{bmatrix}$
It will always transition to the opposite state at each point in time – which definitely does not seem useful.
There's most likely something that I'm misunderstanding in the above, my theoretical grounding isn't very solid.
Note: The transition probability matrix has to be 2 x 2 (it describes the probability of transition between states, including staying in the same state, so both dimensions are equal to the number of states).