OpenCV color concentration histogram

I am working on an ANPR system using OpenCV and have seen in several articles a way to segment characters. The idea is to make a graph showing the color concentration in the image.

How to do it?

enter image description here

This is the image I have:

enter image description here

I need to locate the black areas as shown above to identify each of the characters.

I tried adding values ​​up by pixels per pixel, but I am doing it on Android, and the time it takes is unacceptable.

+8
opencv computer-vision ocr anpr
source share
2 answers

Ok, a month later, but I wrote you some code (in python) for this;)

(Assuming you are only after the image density histogram)

import cv im2 = cv.LoadImage('ph05l.jpg') width, height = cv.GetSize(im2) hist = [] column_width = 1 # this allows you to speed up the result, # at the expense of horizontal resolution. (higher is faster) for x in xrange(width / column_width): column = cv.GetSubRect(im2, (x * column_width, 0, column_width, height)) hist.append(sum(cv.Sum(column)) / 3) 

To speed things up, you do not need to change the image files, just change the width of the selection cell ( column_width in the script), it is obvious that you will lose some resolution if you do this (as you can see in the image below).

In the picture I show the results (graphical hist display) with your file using column_width of 1, 10 and 100. They ran for me for 0.11, 0.02 and 0.01 seconds respectively.

I wrote it in PIL , but it works about 5-10 times slower.

character density histograms

+6
source share

Open OpenALPR ( http://www.openalpr.com ). It performs character segmentation in the same way (using histograms). It's pretty fast on the desktop, but I'm not sure how fast it will be on Android.

-one
source share

All Articles