Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Need suggestions - image segmentation

Subject: Need suggestions - image segmentation

From: Leonardo Oliveira

Date: 11 Aug, 2010 19:04:05

Message: 1 of 15

Hi there.

I actually dont have a question, but am asking for suggestions.
I'm developing a code for car plate recognition and I am stuck on the very end of characteres segmentation.

http://yfrog.com/f/bhimguog/

I have this images above and need to manipulate in a way that remain the important 7 objetcs in each (brazilian car plates: always 3 letters and 4 numbers). In other other words, need to eliminate those undisired yellow and green blocks on the right, left, and possibly in the middle. Theres none in the middle in these examples I gave, but its a possibility and need considerate it, cause i'm using the code for 100+ images later.

As you can see, the objects are labeled and have no connected points.
Please, i dont want a code, but suggestions about what to try next.

Thanks.

Subject: Need suggestions - image segmentation

From: ImageAnalyst

Date: 11 Aug, 2010 19:36:21

Message: 2 of 15

Just count the blobs. Then, if there are more than 7, examine the
first and last to see if they touch the right or left edges. If they
do, get rid of them. Adapt that somewhat for the case like there are
exactly 8, there are 10 or more, they don't touch the right/left
edges, etc.

Subject: Need suggestions - image segmentation

From: Leonardo Oliveira

Date: 11 Aug, 2010 19:52:05

Message: 3 of 15

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <82d0ea12-895c-41c3-ac33-3aa33bbfa70b@q22g2000yqm.googlegroups.com>...
> Just count the blobs. Then, if there are more than 7, examine the
> first and last to see if they touch the right or left edges. If they
> do, get rid of them. Adapt that somewhat for the case like there are
> exactly 8, there are 10 or more, they don't touch the right/left
> edges, etc.

Thanks for the reply.
I'll start by doing this.

But supposing i have an image just like the image 4, but with char 7 touching the right edge. then i have a char touching an edge and that block touching the other edge.
i know none of the images shown is in this situation, but i need a robust code, and probably this will happen sometime.

Do you suggest i should proceed to char recognition with these "bad blocks" and then find a way to say "ok, this is absolutely not a char" and remove it OR you think i could try some other options now and to char recognition when i have the 7 objects alone?

Subject: Need suggestions - image segmentation

From: Leonardo Oliveira

Date: 11 Aug, 2010 19:54:05

Message: 4 of 15

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <82d0ea12-895c-41c3-ac33-3aa33bbfa70b@q22g2000yqm.googlegroups.com>...
> Just count the blobs. Then, if there are more than 7, examine the
> first and last to see if they touch the right or left edges. If they
> do, get rid of them. Adapt that somewhat for the case like there are
> exactly 8, there are 10 or more, they don't touch the right/left
> edges, etc.

Thanks for the reply.
I'll start by doing this.

But supposing i have an image just like the image 4, but with char 7 touching the right edge. then i have a char touching an edge and that block touching the other edge.
i know none of the images shown is in this situation, but i need a robust code, and probably this will happen sometime.

Do you suggest i should proceed to char recognition with these "bad blocks" and then find a way to say "ok, this is absolutely not a char" and remove it OR you think i could try some other options now and to char recognition when i have the 7 objects alone?

Subject: Need suggestions - image segmentation

From: Sean

Date: 11 Aug, 2010 20:19:05

Message: 5 of 15

"Leonardo Oliveira" <leoadeoliveira@gmail.com> wrote in message <i3uv4t$im8$1@fred.mathworks.com>...
> ImageAnalyst <imageanalyst@mailinator.com> wrote in message <82d0ea12-895c-41c3-ac33-3aa33bbfa70b@q22g2000yqm.googlegroups.com>...
> > Just count the blobs. Then, if there are more than 7, examine the
> > first and last to see if they touch the right or left edges. If they
> > do, get rid of them. Adapt that somewhat for the case like there are
> > exactly 8, there are 10 or more, they don't touch the right/left
> > edges, etc.
>
> Thanks for the reply.
> I'll start by doing this.
>
> But supposing i have an image just like the image 4, but with char 7 touching the right edge. then i have a char touching an edge and that block touching the other edge.
> i know none of the images shown is in this situation, but i need a robust code, and probably this will happen sometime.
>
> Do you suggest i should proceed to char recognition with these "bad blocks" and then find a way to say "ok, this is absolutely not a char" and remove it OR you think i could try some other options now and to char recognition when i have the 7 objects alone?


Are these the original images you were given or do you have the unaltered license plate images? I wonder if there might be something you could do to improve the images themselves. Otherwise you have a fun and difficult task.

Subject: Need suggestions - image segmentation

From: ImageAnalyst

Date: 11 Aug, 2010 20:24:10

Message: 6 of 15

I was just trying some simple things to avoid doing OCR on the blobs.
Of course if you make an algorithm that handles what you have so far,
then it's always possible to encounter another brand new image that
makes the algorithm fail in some way. Then you have to build some
more intelligence into the algorithm to handle that new case. And
keep at it until you don't get any more failures with new images.

Subject: Need suggestions - image segmentation

From: Leonardo Oliveira

Date: 11 Aug, 2010 20:48:05

Message: 7 of 15

"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i3v0jp$nbp$1@fred.mathworks.com>...
> "Leonardo Oliveira" <leoadeoliveira@gmail.com> wrote in message <i3uv4t$im8$1@fred.mathworks.com>...
> > ImageAnalyst <imageanalyst@mailinator.com> wrote in message <82d0ea12-895c-41c3-ac33-3aa33bbfa70b@q22g2000yqm.googlegroups.com>...
> > > Just count the blobs. Then, if there are more than 7, examine the
> > > first and last to see if they touch the right or left edges. If they
> > > do, get rid of them. Adapt that somewhat for the case like there are
> > > exactly 8, there are 10 or more, they don't touch the right/left
> > > edges, etc.
> >
> > Thanks for the reply.
> > I'll start by doing this.
> >
> > But supposing i have an image just like the image 4, but with char 7 touching the right edge. then i have a char touching an edge and that block touching the other edge.
> > i know none of the images shown is in this situation, but i need a robust code, and probably this will happen sometime.
> >
> > Do you suggest i should proceed to char recognition with these "bad blocks" and then find a way to say "ok, this is absolutely not a char" and remove it OR you think i could try some other options now and to char recognition when i have the 7 objects alone?
>
>
> Are these the original images you were given or do you have the unaltered license plate images? I wonder if there might be something you could do to improve the images themselves. Otherwise you have a fun and difficult task.


LOL...
But no, these are not the original images.
http://img805.imageshack.us/f/26112002070747.jpg/
http://img339.imageshack.us/f/26112002070750.jpg/
http://img838.imageshack.us/f/26112002070810.jpg/

Ive been working on some algorithms to improve the images, but i think theres not much else to do.
I found the portion of high frequency of the images (supposing the plate location will be this portion) using some windows (considering the 1:9 porportion size of the plates i got). I tried to use some filters to improve the images, but they dont help.
actually, i think i got quite good results on this part.

then i binarized it, removed some small blobs that were on the upper side of the image and not lower side, or were on the lower and not on the upper, unlike the chars, that are on both upper and lower sides.

and now i got these big blobs, that just as the chars, are on the upper and lower sides.

i think i can remove the blob on image 3 and 4 because of the position of the centroid, but blobs like the ones in image 7 are the problem. they quite just like number "1" and letter "I".

anyone have an idea?

Subject: Need suggestions - image segmentation

From: Leonardo Oliveira

Date: 11 Aug, 2010 20:53:05

Message: 8 of 15

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <5529d081-7de5-4c47-838a-164fddffe51a@w30g2000yqw.googlegroups.com>...
> I was just trying some simple things to avoid doing OCR on the blobs.
> Of course if you make an algorithm that handles what you have so far,
> then it's always possible to encounter another brand new image that
> makes the algorithm fail in some way. Then you have to build some
> more intelligence into the algorithm to handle that new case. And
> keep at it until you don't get any more failures with new images.

Yes, i am highly considering that. Your suggestions are good. hope this "brand new image" doesnt shows up.

But i am just giving it a try before moving on. Maybe some solution shows up.

Subject: Need suggestions - image segmentation

From: ImageAnalyst

Date: 11 Aug, 2010 21:55:45

Message: 9 of 15

On Aug 11, 4:48 pm, "Leonardo Oliveira" <leoadeolive...@gmail.com>
wrote:
> i think i can remove the blob on image 3 and 4 because of the position of the centroid, but blobs like the ones in image 7 are the problem. they quite just like number "1" and letter "I".
>
> anyone have an idea?
---------------------------------------------------------------------

Why can't you use my suggestion? You have 9 objects - more than the
required 7. Then you look at the centroids and find the outer two.
Then you notice that they touch the right and left edges, so you zap
those blobs, because you're going to assume that no valid characters
would touch the edge in the event that you have 8 or more blobs. (I'm
leaving out all the MATLAB commands for doing stuff like that because
I'm assuming you know how to do things like that. Let me know if I'm
wrong about that.)

Subject: Need suggestions - image segmentation

From: Leonardo Oliveira

Date: 11 Aug, 2010 23:14:06

Message: 10 of 15

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <694bbc53-c06c-4e15-9902-cf22cbf65770@t2g2000yqe.googlegroups.com>...
> On Aug 11, 4:48 pm, "Leonardo Oliveira" <leoadeolive...@gmail.com>
> wrote:
> > i think i can remove the blob on image 3 and 4 because of the position of the centroid, but blobs like the ones in image 7 are the problem. they quite just like number "1" and letter "I".
> >
> > anyone have an idea?
> ---------------------------------------------------------------------
>
> Why can't you use my suggestion? You have 9 objects - more than the
> required 7. Then you look at the centroids and find the outer two.
> Then you notice that they touch the right and left edges, so you zap
> those blobs, because you're going to assume that no valid characters
> would touch the edge in the event that you have 8 or more blobs. (I'm
> leaving out all the MATLAB commands for doing stuff like that because
> I'm assuming you know how to do things like that. Let me know if I'm
> wrong about that.)

I know the MATLAB commands to do things like that. I just don't want to assume all this stuff.
I'm considering the valid characteres CAN touch the edge, even if I have 9 objects. Maybe one bad blob is between valid characters, like an hifen.

I understand what you suggested and agree it would do OK for most of the cases.
But I actually need a more robust code, and need more mathematical fundamentals to what I am doing than just "ok, valid chars don't touch the edges and it worked just fine".

Hope you understand the real problem I have.

Subject: Need suggestions - image segmentation

From: ImageAnalyst

Date: 12 Aug, 2010 01:05:40

Message: 11 of 15

Then you'll probably need to do full-blown OCR on your blobs, because
you don't want to pay any attention to positional information.

But you'll most likely also need to employ some other "smarts" because
if you have two of your eight blobs that look like "I"s touching your
edge, and six other valid characters in between, how will you know
which outer "I" letter to throw out?

Subject: Need suggestions - image segmentation

From: Leonardo Oliveira

Date: 12 Aug, 2010 02:37:05

Message: 12 of 15

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <c53f9520-2e6e-4e2e-b238-5c5a65a777bb@y11g2000yqm.googlegroups.com>...
> Then you'll probably need to do full-blown OCR on your blobs, because
> you don't want to pay any attention to positional information.
>
> But you'll most likely also need to employ some other "smarts" because
> if you have two of your eight blobs that look like "I"s touching your
> edge, and six other valid characters in between, how will you know
> which outer "I" letter to throw out?

I figured out a way to do it and it's working so far: M is the mean of heights of all blobs in an image, and D is the standard deviation. Then I eliminated blobs w/ height out of the interval [M-D ; M+D]. The chars don't have approx. the same width, but have the height.
Because those bad blobs are usually the borders of the plate itself, and because of it heighter than the chars, or sometimes just little shadows that passed the image processing and binarization along w/ the chars. Then this technique should eliminate then not eliminating the chars, who MUST be inside the interval.

Now I'm testing the algorithm with 60 images. Have to figure out some other things about image processing and then see how good (or bad) this technique is.

Well, it's nice to have some help. This is the first time I use this forum actively. Before I was just reading some questions and answers of others.
Thanks Image Analyst...

I'll be back soon. LOL

Subject: Need suggestions - image segmentation

From: ImageAnalyst

Date: 12 Aug, 2010 02:40:45

Message: 13 of 15

Yeah, that'll work. You could also do things like throw out objects
that don't have bounding box sizes in a certain allowable range, or
have an aspect ratio in a certain allowable range, things like that.
Once you have the allowable blobs, you'll still have to do OCR on
those. Maybe your OCR algorithm might be smart enough to return
"unknown character" if the shape weren't right.

Subject: Need suggestions - image segmentation

From: Leonardo Oliveira

Date: 12 Aug, 2010 03:49:05

Message: 14 of 15

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <927102ba-834c-4167-a19b-c7539b52e8cd@i31g2000yqm.googlegroups.com>...
> Yeah, that'll work. You could also do things like throw out objects
> that don't have bounding box sizes in a certain allowable range, or
> have an aspect ratio in a certain allowable range, things like that.
> Once you have the allowable blobs, you'll still have to do OCR on
> those. Maybe your OCR algorithm might be smart enough to return
> "unknown character" if the shape weren't right.

Yes. I think I'll be more able to develop a good OCR algorithm than an image processing and segmentation algorithm. Think it'll help the image processing by sending back unrecognized plates to be processed in a different way.
Don't know, still gotta think about it.

Subject: Need suggestions - image segmentation

From: Yves Daoust

Date: 13 Aug, 2010 07:15:24

Message: 15 of 15

Leonardo,

If I were to solve this, I would probably
 - develop a heuristic score of the "charness" of the blobs, taking into account the width, the height, the touching of edges, the area and/or the OCR score;
 - consider all sequences of 7 contiguous blobs (if any) by ordering the centroids left to right;
 - compute a global score for each sequence (average or minimum of the blob scores), possibly ignoring the blobs common to all sequence;
 - keep the sequence that has the best global score.

I hope this helps,

 - Yves

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us