Q:

Draw bounding boxes for entire word instead of each character in an image - MATLAB

I have a MATLAB code that draws bounding boxes around each letter.
I would like to draw these boxes around each word, instead of each character.
I had thought of 

reading the size of each space between words and based on that, separating each word.
grouping adjacent rectangles into larger rectangles, which would essentially do the same thing for me. 

How would this be done?

Here is the image so far:
http://imgur.com/iDF5VD4
Here is my code so far:
%CLEAR EVERYTHING
clear all;
close all;

%SET FOLDER AND FILE LOCATION
folder = 'H:\Miscellaneous\Work\Project';
baseFileName = 'lorem-ipsum.jpg';
fullFile = fullfile(folder, baseFileName);

%CONVERT TO GRAYSCALE
normal = imread(fullFile);
gray = rgb2gray(normal);

%CONVERT TO BINARY IMAGE
binary = im2bw(gray);

%INVERT IMAGE
binary = ~binary;

%FILL HOLES
ifill=imfill(binary,'holes');
figure,imshow(ifill)

%COUNT LETTER IN TEXT
[Ilabel num]=bwlabel(ifill);
disp(num)

%CALCULATE REGION PROPERTIES
Iprops=regionprops(Ilabel);

%SET BOX PROPERTIES INTO VARIABLE
Ibox=[Iprops.BoundingBox];

%RESHAPE 1-D ARRAY
Ibox=reshape(Ibox,[4 num]);

%DRAW BOUNDING BOXES FOR EACH LETTER
for cnt=1:num
    rectangle('position',Ibox(:,cnt),'edgecolor','r');
end
hold off

A:

I think you've got a good idea. You group letter boxes into words, then compute the bounding box of each group.
In your particular example, you can do this very fast with morphological closing. I don't explain here how to compute the word spacing, you only need the character spacing which is a parameter of the used font. I call this parameter Sp. On your image, Sp seems to be approximately 4 pixels.
So, first take your binary image; note that filling the holes is very interesting here. With morphological closing, you can work directly on the letters, no need to work with their bounding boxes. 
binclosed = imclosed(binary, strel('rectangle',[2 ceil(Sp/2)]));

Here I close with a rectangle of height 2 in order to, for example, catch the dots of 'i').
Then you can label the connected components and draw their bounding boxes as you have done for characters.
[Ilabel,num] = bwlabel(binclosed);
Iprops = regionprops(Ilabel, 'BoundingBox');
Ibox = reshape([Iprops.BoundingBox],[4 num]);
for cnt=1:num
    rectangle('position',Ibox(:,cnt),'edgecolor','r');
end

