MATLAB: Graph the randomization of a binary image

boundarydigital image processinggraphImage Processing Toolbox

I have zero MATLAB experience, but have been asked to work in it to do some image analysis. I'll try and ask my question as specifically and concisely as possible.
Imagine the following binary image exemplified by the matrix below. This is a simplified version of the images I'll be working with:
0 1 0 1
0 1 1 1
0 0 0 1
0 1 1 1
I want to construct a graph that will represent the randomness of each column. My thought is to develop a random index = the total transitions between each value in the column / by the total possible transitions. In the matrix above, each column could have a total possible of 3 transitions.
For the example above: column 1 would have a random index of 0 (0/3)
Column 2 would have a random index of 66.7 (2/3)
Column 3 = 100% (3/3)
Column 4 = 0 (0/3) even though they are 1's and not 0's. Doesn't matter, I just want the transitions.
Can I draw a boundary around all the 1 values and then have MATLAB sum all of the boundaries(only idea I have)?
Again, I have zero experience in MATLAB, but have been asked to do this (for me) impossible task. Any help would be greatly appreciated!

Best Answer

Take a look at the diff() function.
m=[...
0 1 0 1
0 1 1 1
0 0 0 1
0 1 1 1]
dm = diff(m)
randomnessIndex = sum(abs(dm))/(size(m, 1)-1)
m =
0 1 0 1
0 1 1 1
0 0 0 1
0 1 1 1
dm =
0 0 1 0
0 -1 -1 0
0 1 1 0
randomnessIndex =
0 0.66667 1 0