Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am using OpenCV and c++. I have black and white image after binarization. How can I calculate area of object when I have only one coordinate of point (x,y) belongs to this object??
since it's a binary image, you can easily get the blobs. Once you get the blobs, you can easily calculate the blob area.
You can use cvBlobsLib to get the blobs. OpenCV hasn't integrated cvBlobsLib. You can do it by yourself. But OpenCV has functionality for contours. You can use findContours to get blobs/contours and then get the area. OpenCV - findContours
OpenCV - Structural Analysis and Shape Description
You'll find information about moments, huMoments, contours, etc. Using moments, you can create your own blobs and it will also help you in getting the blob area.
Here's an Open Source framework for machine vision which uses Python bindings of OpenCV - SimpleCV
They have implemented a complete blob functionality using contours and moments. You can have a look.
Blob
BlobMaker
It's written in Python, but you can port it to C++ and use blobs.
The algorithm is very easy and should be the following:
Find all contours on your image.
Cycle through all contours and check if point is inside a contour.
If contour is found than calculate it's area.
You have to write some kind of region growing algorithm, starting from your startpoint, incrementally adding adjacent pixels that are of the same color.
A lazy (and much slower) way to do it would be to use cv::floodFill function, setting up the pixels in your shape to a specific color, then counting the pixels in you image that have this specific color.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I understand that the the convert -unsharp from ImageMagick is using Unsharp Masking to sharpen the image. What kind of algorithm is behind convert -adaptive-sharpen? When I want to sharpen my lanscape images, which algorithm should I use? What are the advantages and disadvantages for the two algorithms?
I'm not an expert on the algorithm, but both operations achieve the same goal by creating a "mask" to scale the intensity of the sharpening. They differ on how the generate the "mask", and the arithmetic operations.
With -unsharp
Given...
For demonstration, let's break this down into channels.
Create a "mask" by applying a Gaussian blur.
Apply the gain of the inverse mask if threshold applies.
Ta-Da
With -adaptive-sharpen
Given...
For demonstration, let's break this down into channels (again).
Create "mask" by applying edge detection, and then Gaussian blur.
Apply sharpen, but scale the intensity against the above mask.
Fin
Which command will give the better results for normal outdoor images?
That depends on the subject matter. It's a good rule-of-thumb to use -adaptive-sharpen if the image contains large empty space (sky, sea, grass, &etc), or bokeh/blurred background. Else -unsharp will work just fine.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am doing a project which is hole detection in road. I am using a laser to emit beam on the road and using a camera to take a image of the road. the image may be like this
Now i want to process this image and give a result that is it straight or not. if it curve then how big the curve is.
I dont understand how to do this. i have search a lot but cant find a appropriate result .Can any one help me for that?
This is rather complicated and your question is very broad, but lets have a try:
Perhaps you have to identify the dots in the pixel image. There are several options to do this, but I'd smoothen the image by a blur filter and then find the most red pixels (which are believed to be the centers of the dots). Store these coordinates in a vector array (array of x times y).
I'd use a spline interpolation between the dots. This way one can simply get the local derivation of a curve touching each point.
If the maximum of the first derivation is small, the dots are in a line. If you believe, the dots belong to a single curve, the second derivation is your curvature.
For 1. you may also rely on some libraries specialized in image processing (this is the image processing part of your challenge). One such a library is opencv.
For 2. I'd use some math toolkit, either octave or a math library for a native language.
There are several different ways of measuring the straightness of a line. Since your question is rather vague, it's impossible to say what will work best for you.
But here's my suggestion:
Use linear regression to calculate the best-fit straight line through your points, then calculate the mean-squared distance of each point from this line (straighter lines will give smaller results).
You may need to read this paper, it is so interesting one to solve your problem
As #urzeit suggested, you should first find the points as accurately as possible. There's really no way to give good advice on that without seeing real pictures, except maybe: try to make the task as easy as possible for yourself. For example, if you can set the camera to a very short shutter time (microseconds, if possible) and concentrate the laser energy in the same time, the "background" will contribute less energy to the image brightness, and the laser spots will simply be bright spots on a dark background.
Measuring the linearity should be straightforward, though: "Linearity" is just a different word for "linear correlation". So you can simply calculate the correlation between X and Y values. As the pictures on linked wikipedia page show, correlation=1 means all points are on a line.
If you want the actual line, you can simply use Total Least Squares.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
A lot of research papers that I am reading these days just abstractly write image1-image2
I imagine they mean gray scale images. But how to extend these to color images ?
Do I take the intensities and subtract ? How would I compute these intensities by taking the average or by taking the weighted average as illustrated here?
Also I would prefer if you could quote the source of this as well preferably from a research paper or a textbook.
Edit: I am working on motion detection where there are tons of algorithms which create a background model of the video(image) and then we subtract the current frame(again a image) from this model. We see if this difference exceeds a given threshold in which case we classify the pixel as foreground pixel. So far I have been subtracting the intensities directly but don't know whether other approach is possible.
Subtraction directly at RGB space or after converting to grayscale space is possible to miss useful information, and at the same time induce many unwanted outliers. It is possible that you don't need the subtraction operation. By investigating the intensity difference between background and object at all three channels, you can determine the range of background at the three channels, and simply set them to zero. This study demonstrated such method is robust against non-salient motion (such as moving leaves) with the presence of shadows at various environments.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am currently studying a computer vision module in college.
I would like to get a theoretical understanding of what contours are in computer vision and what they are used for.
A contour is simply the boundary of an object in an image. Various representations of contours (e.g. chain code, Fourier descriptors, shape context) are used to recognize or categorize objects.
This assumes that you have a way to segment out an object and find its boundary, which itself is not a trivial problem. One particular class of algorithms for finding boundaries is called active contours or snakes. Is this what you are asking about?
Here you can go through the official documentation of opencv, where they say that contour is a simple curve which joins continuous points with same color or intensity.
I used the concept of contours in hand gesture recognition where i have used the area bounded by contours as a basis to remove the noise and detect only the hand part in the image.
Contour is a boundary around something that has well defined edges, which means that the machine is able to calculate difference in gradient (significant difference in magnitude of pixel value), try to see if the same difference continues and forms a recognisable shape and draw a boundary around it. Opencv can do it for a lot of shapes and they are shown in the link below.
Just imagine how you do it with your eyes. You're in a room and you create a boundary in your mind when you see a frame or a monitor or a ball. Exactly the same way contours work in opencv. As #Dima said, various algorithms are used for this purpose.
If you need examples and how contours are represented in opencv, here's a link.
Hope this helps.
Open CV python provides us with contours and several edge detection features to identify several attributes of objects. Contours can be explained simply as a curve joining all the continuous points(along the boundary), having same colour or intensity.
Use of binary image in contour detection:
Contours are useful tool for shape analysis and object detection and recognition. We take in binary image (in other words, images whose pixels have only 2 possible values).So before finding contours, apply threshold or canny edge detection.
Steps for finding the contours:
1)Convert to grayscale
2)Convert to binary image
3)Find contours
Draw contours :
To draw the contours, cv2.drawContours function is used. It can also be used to draw any shape provided you have its boundary points.
Properties of contours:
1)To find the area.
2)To find the perimeter
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
My task is to pin-point where is the plate number in an image. The image does not only contain the plate number. It may contain the whole car or anything. I used gaussian blur then grayscale then contrast then laplacian of gaussian to detect the edges.
Now, I am at loss on how to detect where is the plate number in the image. I am not going to read the license number, just make the system know where is the license number.
Can you direct me to a study regarding this? Or perhaps the algorithm that can be used to do this.
Thank you!
I think a more robust way to tackle this is a train a detector if you have enough training images of the license plate in different scenarios. Few things you can try is Haar cascade classifier in Opencv library. It does a multiscale detection of learned patterns.
You could try edge detection or some form of Hough transforms.
For example, do edge detection and then look for rectangles (or if the images aren't straight on, parallelograms) in the image. If you know that the plates will all be the same shape and size ratios, you can use that to speed up your search.
EDIT:
Found this for you.
Using some feature recognition algorithm e.g. SIFT would be a good starting point. Do you need real-time recognition or not? I recommend trying to tighten search space first, for example by filtering out regions from the image (is your environment controlled or not?). There is an article about recognising license plates using SIFT here (I just skimmed it but it looks reasonable).
License-plates or number plates of vehcles come with 2 striking properties.
They have specified color pattern (Black letters on white, yellow or gray background)
Aspect ratio
These properties can be used to extract only the license plate. First threshold the image using adaptive thresholding. Then find contours in the image with aspect ratio in a close range to standard value. This method should work for most of the cases. You can also try erosion followed by dilation of thresholded image to remove noise.