How to use a histogram to get the white pixel intensity? - c#

I am developing a number plate recognition system and I have managed to locate the number plate area successfully. But I need to filter out the false number plate areas from the image. I am thinking is to use a histogram and probably check the horizontal pixel intensity.
would this be a correct approach? or are there any better approach?

The plate is an aerea of high contrast, you should take advantage of that. Also there are a lot of edges, and especially 90 degrees edges.

Take a look at this example using EmguCV in C#, maybe you can find something useful, it is example of recognizing a stop sign: Stop sign detection

Related

How does math.perlinnoise work in unity? I know how to use it but i don't know it's formula, etc

I'm relatively new to unity and I am currently following a tutorial that uses math.perlinnoise to generate some terrain, but the tutorial doesn't explain how it works so I decided to research it online. I know how to use it but i don't know how it works. All i know is that if i insert 2 decimals that aren't whole numbers, it will return a float. I tried searching some explanations online but all of them were in languages that I'm not familiar(c# is the only language that i understand) and also did not use unity's version of mathf.perlinnoise(i don't know whether or not they're different, though). So could anyone provide any sources that are in C# or give some sources that i can study? Thanks in advance.
Perlin Noise is essentially a grid of gradients from a minimum value to a maximum value, each rotated at a random angle. The gradients at each point are smoothed based on the surrounding points, creating a smooth wavy grid.
Unity's Mathf.PerlinNoise specifically ranges from 0.0 to 1.0, but often the algorithm is implemented ranging from -1.0 to 1.0.
A visual example of the process is available on Wikipedia. In those images, the dark purple represents the value -1, and the dark green is the value 1.
You can imagine the low numbers (purple) being valleys, and the high numbers (green) being hills. You can also add more layers of perlin noise at different scales to add more detail and reduce the smoothness.
A great tutorial on algorithms behind various kinds of noise, using C# and Unity, is available by Catlike Coding.

Get diameter of circle in bitmap

My problem is following. I need precisely measure diameter of circles in bitmap.
I have Bitmap with several circles. Some of them are concentric. I need values of their diameters.
I tried OpenCV and EmguCV and their method HoughCircles. But this method find circles on the places where is are no circles (I tried a lot of combinations of input parameters). Ad if it finds them there is no case, when it found exatly same circle as in the bitmap. Their centers and diameters are different then circles on the original picture. So this method is only for some kind of game. Not for my purpose(precise measuring for industry).
Do you know some way or algorithm how to do it? (I prefer C#, but if it will be in pseudocode or different langueage, I will rewrite it)
Thanks in advance.
If you could detect circles, you may benefits from this opencv function findContours() in order to get all circles as contours, then you will be able easily to calculate their areas
Then, use this formula Area = pi*r^2 to calculate r.
diameter = 2*r
You are asking for an answer to a very hard problem. The hough algorithm is not a toy solution, but it is not appropriate for all machine visions circle detection situations. Human eyes are very good at such thing (if a bit imprecise). You basically need to know a lot more about your data to approach a robust solution.
Take a look at this dicussion about Hough Circle detection as well as this paper Hough Circle Transform for a deeper understanding of the limitations
You might also want to review this paper on the ant system for ideas on a different approach.
You also might want to read up on Morpological thinning as a possible pre-preprocessing step before Houghton
Best of luck

Finding a pattern in latitude & longitude

I have a series of Lat/Long points in a SQL Server database. I would like to be able to find shapes. By that I mean if in the mess of coordinates there are 8 coordinates making a perfect circle, or 7 coordinates making a triangle I would like to know.
I'd be surprised if there is already something out there which does this already, especially in C# (the language I'm using). But My question is really, how should I approach this?
I probably have 200k, but their timestamped, so I should only be working with maybe 1k at a time...
What you're trying to do is called least squares fitting.
Basically, you pick a shape. Let's pick a straight line for now.
You calculate the sum of the squares of the offsets ("the residuals") of the points from the line. You do this with different lines until you've minimized the sum of the squares.
I have no idea how you would automate this for several types of shapes.
You need to find a library, or develop your self, a way to calculate Least Squares over shapes.
If the error margin is over a threshold level of R2 then you do not have that "Shape". You will need to define a formula for the shape you test against (For example a circle: x2+y2=r2).
For things that do not have curves (triangle,square, ect.) it will be harder to do as they do not have a "Formula". You can use the least square for finding each side of the shape for a line (y=mX+b) and then building those lines together to make shapes.

How to implement smoothing in frequency domain?

I want to do smoothing to an image in the frequency domain. when i use google to see any articles it gave some Matlab codes which i don't need. i could do FFT to an image but i don't know how to implement any smoothing techniques(ILPF, BLPF, IHPF, BHPF) in frequency domain. if you can provide any code samples for any of the above techniques WITHOUT using any image processing libraries it will be really helpful and C# is preferred.
Thanks,
Could you define what you mean by 'smoothing in the frequency domain'? You can generate a spectrum image using FFT and multiply the image by some function to attenuate particular frequencies, then convert the spectrum back to an image using the inverse-FFT. However, for this kind of filtering (multiplication by some scaling function in frequency), you can achieve the same result more quickly by convolving with the dual function in the spatial domain.
In any case, if you wish to implement this yourself, read up on FFT (the fast Fourier transform) and convolution. You might also check out a signal processing textbook, if you're interested, as the theory behind discrete filtering is fairly deep. The algorithms won't make a whole lot of sense without that theory, though you can certainly apply them without understanding them.
If you want to implement your own DSP algorithms, check out this book online. In particular, Ch 33 describes the math and algorithm behind Butterworth filter design. Ch 12 describes how to implement FFT.
There is a great series on Code Project by Christian Graus which you might find useful, especially part 2 which deals amongst others with smoothing filters:
Image Processing for Dummies with C# and GDI+ Part 1 - Per Pixel Filters
Image Processing for Dummies with C# and GDI+ Part 2 - Convolution Filters
Image Processing for Dummies with C# and GDI+ Part 3 - Edge Detection Filters
Image Processing for Dummies with C# and GDI+ Part 4 - Bilinear Filters and Resizing
Image Processing for Dummies with C# and GDI+ Part 5 - Displacement filters, including swirl
Image Processing for Dummies with C# and GDI+ Part 6 - The HSL color space
Keshan, it is simple. Imagine the FFT is another two pictures where low frequencies lie in the middle and high frequencies away from the middle. If the pixels are numbered from -w/2 to w/2 and -h/2 to h/2 you can simply measure the distance from the middle as a(x,y)=sqrt(x^2+y^2). Then take some arbitrary monotonic decreasing function like f(x)=1/(1+x) and multiply each point in the fft with f(a(x,y)). Then transform back using the FFT.
There are different choices for f(x) which will look different. For example a gaussian function or bessel or whatever. I did this for my undergrad and it was great fun. If you send me a mail I will send you my program :-).
One bit caveat is the ordering in output of the fft. The arrays it generates can be ordered in weird ways. It is important that you find out which array index corresponds to which x/y-position in the "analytical" fourier transform!
For all image/signal processing I recommend OpenCV.
This has a managed C# wrapper: Emgu.
http://www.emgu.com/wiki/index.php/Main_Page

filter pornography in a video/picture c# library

How can you filter pornography in a video/picture?
Is there a library I can use? Commercial or open source is OK.
For Video:
You would analyze the sound waves from the video. If there's lot of grunting and moans, find a way to recognize those patterns and label it as porn. However, you might get false tags for women's tennis match.
For Image:
Build a simulation model of a human brain which signals arousal from viewing erotic pictures. Some paramters would be excessive curves, and image recognition of the human anatomy. This is far more difficult.
If it is not a real-time, you could use Amazon's Mechanical Turk to do the work. You'll have to pay the workforce, but it's a very cheap way to get menial jobs like this done.
See, Porn Detection is not a very easy.
But there is surely a range of color that identifies the human skin. And you need to make a threshold of the color to identify the picture as porn. Say you take it as 70 %, so you go through all the pixel on the current screen and determine whether 70% of the pixels comes within the range of human skin color.
There is already few algorithm prepared for Face detection like :
http://www.codeproject.com/KB/cs/Face_Detection_processing.aspx
I hope this would help you to find a way on your point.

Categories