# Partitioning an image based on features

I have an image that has various characters hand drawn in it, like numbers and letters. I'm trying to partition each character into it's own image so I can run it through Classify[] and identify them one at a time (since TextRecognize[] doesn't work well on individual characters). My images look like this:

That's a bunch of 1's for putting into Classify[]. So it should be pretty easy to partition each one, but I'm not sure what the best way to do it is. I tried adapting this example: http://reference.wolfram.com/mathematica/example/AnalyzeSegmentedCellsInAnImage.html

but I couldn't get it to work.

characters =
SelectComponents[
DeleteBorderComponents[Binarize[a, {0, .7}]], {"Area"},
100 < #1 < 1000 &];

outlines =
ComponentMeasurements[
ImageMultiply[a, characters], {"BoundingBox"}][[All, 2]];

Show[a, Graphics[{Red, Thick, Circle @@ # & /@ outlines}]];


This just returns a slightly lighter version of the original image with no red anywhere.

-
Classify ? Are you implementing it ? You can post the code as it is related. – Sektor Apr 12 '14 at 19:11
@Sektor, Classify is a new function in v10 – Simon Woods Apr 12 '14 at 20:20
@SimonWoods Yeah, he just did not specify .. :) – Sektor Apr 12 '14 at 21:14

You can use ImageTrim to extract the bounding boxes from the image.

image = Import["http://i.stack.imgur.com/GjN95.jpg"];

m = MorphologicalComponents@Binarize@ColorNegate@MinFilter[image, 1];
m = SelectComponents[m, "Elongation", # > 0.8 &];
c = ComponentMeasurements[{m, image}, "BoundingBox"];

ImageTrim[image, #] & /@ c[[All, 2]]


-
nice and short! – chris Apr 12 '14 at 20:08