Image OCR - Filtering unwanted data - c#

Basically I'm reading vehicle license plates using tessract OCR, however despite being able to emphasise text easily enough via changing contrast, reducing noise an so on, some 'parts' of the vehicle remain on the image which does cause the OCR to throw bad results.
For example take:
I can change this easily enough, such as:
I'm looking to eliminate the edges off each plate, here's another example:
I could remove the edges using pixel manipulation algorithm, however I don't feel it's the right method, and would cause quite a lot of problems.
I've been using the following application to test various methods such as morphology and eliminating the unwanted data, so far I haven't been successful.
http://www.codeproject.com/KB/GDI-plus/Image_Processing_Lab.aspx
However someone with knowledge of this could use the application on the article above to achieve want I'm trying, so feel free to give it a try.
Thanks

Please try to use stroke width transformation concept.
This concept use to segment text from natural images.....

I already did such an algorithm. I just can say that it works great. The secret is, that you need to know that the light is coming just from one side perhaps. You cannot set the image to "black/white" just by using ONE threshold.
Detect the average luminance of parts of the image and use this luminance calculation to set the threshold for each region.
For example, if the left top is lighter, you need a lower threshold to make these parts not to bright. And if the bottom right has low light, you need to set the threshold higher to receive all existing light information.
Then, you need just to drive into the image from each side by using the method:
IsPixelAboveThreshold ?
If it is below, you are on the border, if it is above, you can say you are on the middle of the image with more brightness.
Regards

Related

Split image in parts

I want to be able to reproduce something like this image (taken from NBA.com )
What I have :
- A court with the white lines
- A list of Position for each shot and I know if they are made or missed.
But I'm stuck on the method to realize the image :
Should I create images for each part of the field using photoshop/paint.net and then color it in c# ?
Of course the best way would be to have an equation for each part so I can check easily if the position is in and I could also draw it.
How would you do it ?
You need to first decide on how replicable you need the solution. If you need it for a 1-10 pictures, then don't bother with code- it will most surely take much longer to fine tune it.
If was to work on this specific image, I would probably take my time to find expressions for all lines to make calculations more precise though.

Detection of defacts during video rendering ( which algorithm to use)

I would like the system to pin point/highlight the deformed area to the user during video rendering. Lets say currently I have an image with a list of squares as shown in the image below, this is the original image without defects.
In the following image, is the sample image that consist of a defect, whereby there is an extra line in between the squares.
I would like to have something as shown in the sample image below where by it will have a red square to highlight the "extra line" to inform the user that there is a defect and will pin point the defect to the user.
The defects may appear in any kinds of shapes or forms, and I would like to pin point the defects to the user. So what kind of algorithm I should use in order to achieve this?
Also, is machine learning required in order to achieve this?
Currently I am using Emgucv in C#, but I am not sure what algorithm I should use that can achieve this. Any suggestions are appreciated.
Thank you.
You could just to an cv::absdiff to find the changed areas. After that, use findcontours to group the defects and draw an outline around them.

Comparing focus of 2 image

I'm trying to develop object detection algorithm. I plan to compare 2 image with different focus length. One image that correct focus on the object and one image that correct focus on background.
By reading about autofocus algorithm. I think it can done with contrast detection passive autofocus algorithm. It work on light intensity on the sensor.
But I don't sure that light intensity value from the image file has the same value as from the sensor. (it not a RAW image file. a jpeg image.) Is the light intensity value in jpeg image were the same as on the sensor? Can I use it to detect focus correctness with contrast detection? Is there a better way to detect which area of image were correct focus on the image?
I have tried to process the images a bit and I saw some progress. THis is what I did using opencv:
converted images to gray using cvtColor(I, Mgrey, CV_RGB2GRAY);
downsampled/decimated them a bit since they are huge (several Mb)
Took the sum of absolute horizontal and vertical gradients using http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=sobel#cv.Sobel.
The result is below. The foreground when in focus does look brighter than background and vice versa.
You can probably try to match and subtract these images using translation from matchTemplate() on the original gray images; and then assemble pieces using the convex hull of the results as initialization mask for grab cut and plugging in color images. In case you aren’t familiar with the grab cut, chceck out my answer to this question.
But may be a simpler method will work here as well. You can try to apply a strong blur to your gradient images instead of precise matching and see what the difference give you in this case. The images below demonstrate the idea when I turned the difference in the binary masks.
It will be helpful to see your images. It I understood you correctly you try to separate background from foreground using focus (or blur) cue. Contrast in the image depends on focus but it also depend on the contrast of the target. So if the target is clouds you will never get sharp edges or high contrast. Finally jpeg image that use little compression should not affect the critical properties of your algorithm.
I would try to get a number of images at all possible focus lengths in a row and then build a graph of the contrast as a function of focal length (or even better focusing distance). The peak in this graph will give you the distance to the object regardless of object's own contrast. Note, however, that the accuracy of such visual cues goes down sharply with viewing distance.
This is what I expect you to obtain when measuring the sum of absolute gradient in a small window:
The next step for you will be to combine areas that are in focus with the areas that are solid color that is has no particular peak in the graph but none the less belong to the same object. Sometimes getting a convex hull of the focused areas can help to pinpoint the raw boundary of the object.

wpf custom control: audiowaveform rectangle with selection slider

I'm working on a c# wpf app in which I want to do something with audio. the irrklang audio library provides me with a pcm decoded 16 bit byte array.
I want to create a timeline control which shows the waveform along the timeline with an overlaying rectangle which the user can drag and click/drag the left and right side to increase or decrease the selection.
It is used to the trim the audio track. I would like the selected min and max to be databindable, the minimum and maximum value of the total track to be bindable.
To clarify here is an image mockup:
I'm not asking for a complete control but tips and suggestions on how to tackle this are more than welcome. Perhaps solutions like this already exist but so far I haven't been able to find it.
I think I need to tackle: the control (zooming, panning and changing the selection) and drawing the waveform in the control
Thanks in advance,
I think you should check out this codeplex project
http://wpfsvl.codeplex.com/
Refer to Audio WaveForm Drawing Using WPF.
Something based upon WaveFileTrimmerControl.xaml would be useful, it uses related controls PolygonWaveFormControl.xaml & RangeSelectionControl.xaml (links are to the XAML but refer to the CS also). In any case it'd be a good starting point for building a control that exactly meets what you want.
You could override the render method and use primitives which will give possibly better performance; but like anything related to performance I'd try the above approach first which is almost certainly good enough.

What is the best algorithm to locate a point in an image file?

I want to create a mark sheet recognizer.
Here is the description:
My system uses black and white color scheme.
The mark sheet paper has a small black rectangle on each corner and an additional small black rectangle, to determine orientation, near one of the previous rectangles.
The paper is scanned to yield an image (in bmp format for example).
The first step is to locate these five references in image as eficient as possible.
My rough idea is to trace row by row and from left to right for each row.
It sounds very slow I think.
Is there any better way to do that?
Thank you in advance.
regards,
Suugaku
You can start by searching where you typically expect to find the reference images. You can do this by keeping statistics of where they were before. In particular if you have two frames taken one after the other, the chances are the reference points won't have moved very far.
Once you have found one or more of the reference points, the position of the others becomes heavily constrained so you can make a very good guess as to where the others must lie. Each time you find a new point it provides more hints as to where the remaining points can be.
So you can start by using a bit of guesswork to find the points quickly, and revert to a line-by-line scan if that fails.
Speed is not an issue if you use the BitMap.LockBits() instance method (https://web.archive.org/web/20121203144033/http://www.bobpowell.net/lockingbits.htm). Then, all you need is a couple of hours.

Categories