One easy way to create your boxes is to sum your image down each column and look for where the sum falls below a certain threshold (i.e. where white pixels drop below a given number in this column). This will give you the indices of the columns where the fields should be. The width of these cells may be too narrow (i.e., small parts of the digits may protrude sides), so you can expand the edges by folding the index vector with a small unit vector and search for resulting values ββgreater than zero. Here is an example of using your image above:
rawImage = imread('license_plate.jpg'); %

Note. The above threshold value suggests that a black and white image can be of type double (with values ββ0 or 1), logical (also with values ββ0 or 1), or an 8-bit unsigned integer (with values ββ0 or 255). All you have to do is set N to the number of white pixels to use as a threshold for identifying a column containing part of the number.
gnovice
source share