Python Opencv - Find black dots inside contours - python

I'm using the python wrapper for OpenCV 2.1. (I can't use any external library)
Does anyone know how can I find a black dot put inside other 2 concentric black shapes?
Now I'm using cv.FindCountours to detect the black areas, but then I don't know how to discard the 2 concentric shapes and keep only the internal dot
link to image: http://img848.imageshack.us/img848/2797/visiodrawing11.png

First update the OpenCV to 2.3.1
1) find all the contours after inverting image color.
2) Find their area.
3) Select the contour with minimum area or minimum perimeter.
4) That will be the center point. You can copy it to another image.

Related

Fill outside of contour with white OpenCv Python

I am trying to find the contour with the largest area and fill the outside of the contour with white. I have looked at this Question
The solution works well when using many contours but when I try to use it with one contour it only shows the contour with the inside and outside black. I am trying to rather create a mask that only leaves the interior area of the contour. I am using max(contours, key=cv2.contourArea) to get the largest contour. Using OpenCv, Python

Identifying L shapes in an image using Python

How would i go about extracting the region of interest - which is the rectangle enclosed by the L shaped lines. Are there any functions in opencv or skimage that would help me with this? I am working with Python.
Note - The green boxes were drawn by me to highlight the ROI
I was able to solve this by taking contours and drawing a min bounding rectangle around the contours.
There were still couple of exception cases to be handled such as - what if there are other contours whose min bounding rectangle overlaps the contours of the L shaped images , but for now i am happy with this result. Thanks for all the comments

Python - How to detect hard edges of multiple thumbnails and save the coordinates?

We have a scanned white page - A4 size that contains multiple thumbnails.
The thumbnails are similar but not exactly the same.
The thumbnails can be in random order and not in a very clear rows and columns. They are not totally random but they are in rows, however these are not a very accurate rows.
A4 page background color is white.
All thumbnails have black border of 5px and border-radius of 10 px
Everyone of the thumbnails contains a green circle (Could be in the center or somewhere close to that).
1. How can we detect the Hard Edges of every thumbnail and store the coordinates so we can crop the thumbnails for later processing and analyzing colors?
2. How can we detect the circle in the center. We want to analyze and get all pixels RGB values contained into this circle and then calculate average RGB value.
Update
This is the image:
Thank you
Main idea: As there are enough blank between the regions, so just crop each region by contours. Then for each region, use houghCircle to detect the circle in it.
Your image is this:
After find external contours and calculate the bounding boxes:
For each contour, crop and find hough circle in it.
Notice: I'll not provide my code for this question.
But post some links maybe useful for you. Learn and do by yourself:
Copy shape to blank canvas (OpenCV, Python)
cv2.drawContours() - unfill circles inside characters (Python, OpenCV)
How to detect colored patches in an image using OpenCV?
Edge detection on colored background using OpenCV
How can I get the minimum enclosing circle with OPENCV?
How can I prepare circle path text image for OCR program?
Update:
To detect the circle, you should select the right parameters, depends on your source image.
Try! Try! TRY!
Here is the circle detection I tried:
circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT,
dp=1, minDist=20, circles=None,
param1=200 , param2=50,
minRadius=120, maxRadius=150
)

How to find the largest empty rectangle using OpenCV?

I need to find the coordinates of the largest empty rectangle in a PNG image. The rectangle should consist of light colors (if that is too difficult, white pixels only are fine) and should be axis-oriented.
I am new to computer vision and I found out about OpenCV, I am currently using the python interface to it and started tackling this problem with the SimpleBlobDetector interface, but it gives me only the center of the Blob with a certain radius.
Can anyone point me in the right direction for this?
EDIT: I need to do this with a regular colored PNG image, not a binary matrix
You can use a contour extractor, with the given point list you can check the size of the rectangle by checking the sizes of the lists, assuming that all the rectangles are parallel to the cardinal axis. If not you need to compute the distance of a pixel and the next for all the pixels in the contour list by using the x and y coordinates on each.

OpenCV: How can I calculate the area of a white region?

I have a black image with a big white spot on it and I want to calculate the area of this white spot. Which is the best way to calculate this ? I'm using OpenCV in Python.
To find the Area follow these steps:
Apply thresholding & Binarize the input image.
Find Contours.
Find the Area of Contours by using cv.ContourArea();
refer this example for further reference.

Categories

Resources