# MATLAB: How to find pixel connect in column matlab

connected lineimage processingsum columnvalue

I have line picture. and I want to sum column.
if value in column connected same column 3 and 4. count 1
if is not connected -> plus
Ex. pic
pic = [      0 0 0 0 1 0 0 0 0 0      0 0 0 1 0 0 0 0 0 0      0 0 0 0 1 0 0 0 0 0      0 0 0 1 0 0 0 0 0 0      0 0 0 1 0 0 0 0 0 0      0 0 0 1 0 0 0 0 0 0      0 0 1 0 0 0 0 0 0 0      0 0 1 0 0 0 0 0 0 0      0 1 0 0 0 0 0 0 0 0      1 0 0 0 0 0 0 0 0 0]      
result = 1 1 1 2 2 0 0 0 0 0
Thank you.

pic = [      0 0 0 0 1 0 0 0 0 0      0 0 0 1 0 0 0 0 0 0      0 0 0 0 1 0 0 0 0 0      0 0 0 1 0 0 0 0 0 0      0 0 0 1 0 0 0 0 0 0      0 0 0 1 0 0 0 0 0 0      0 0 1 0 0 0 0 0 0 0      0 0 1 0 0 0 0 0 0 0      0 1 0 0 0 0 0 0 0 0      1 0 0 0 0 0 0 0 0 0][rows, columns] = size(pic);for col = 1 : columns	[~, result(col)] = bwlabel(pic(:, col))end