How to obtain the array of black pixel columnwise??

2 views (last 30 days)
here I want to get the size of the letter.For that i want the array of black pixels columnwise.I know to calculate the entire pixels of the word.But please help me with this.

Accepted Answer

Walter Roberson
Walter Roberson on 15 Dec 2015
col_idx_first_black = sum(cumprod(YourImage,1)) + 1;
col_idx_last_black = size(YourImage,1) - sum(cumprod(flipud(YourImage),1));
col_letter_size = max(0, col_idx_last_black - col_idx_first_black + 1);
Note: col_letter_size will be 0 for columns that contain no black. The first occupied row for the column will be in col_idx_first_black and the last occupied row for the column will be in col_idx_last_black (but those will have misleading values if the row has no black.)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!