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
Related
I am looking to fill the area under a boundary with white color. I basically have an image with the red boundary detected through the findContours method
I am now looking at filling the area below this detected red boundary with white color. This would allow me to distinguish between the area below the red boundary and the area above for a histogram computation.
Can someone help me with this? Open to suggestions outside OpenCV as well, if it's easier to implement.
You are drawing after findContours operation. you can get the points(x,y) you are painting and you can calculate it with a simple row to column ratio.
I am writing a program to analyze microscopy images. I have an edge mapping of an image that looks like this:
The program I have written draws bounding boxes around circular shapes, but when the contours are not closed (like in the image above) it struggles and the resulting bounding box can include multiple circles.
So given this image, is there a way to differentiate between the two circular (or ovular) bodies, so the bounding boxes accurately enclose each shape?
(The image is an example of a bounding box incorrectly drawn around multiple circles)
If all/most your error cases look like the above one, i.e. with bounding boxes that should be further subdivided, you could try to use robustified fitting of ellipses to the edge points.
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
)
I have an image Original Image, and I would like to find the contour that encloses the box in the image. The reason for doing this, is I would like to then crop the image to the bounding box, and then perform further image processing on this cropped image.
I have tried detecting Canny edges, however they seem not to be connecting as I want them to. Attached is an image of how the canny edges look. Canny edges
gray = img[:,:,1]
blurred = cv2.GaussianBlur(gray, (5, 5), 0)
edged = cv2.Canny(blurred, 20, 60)
What is the best way to find the bounding box from the original image?
Many thanks.
Let me know how I can make this question clearer if possible too!
I assume the following: (if this is not the case you should specify such things in your question)
You know the size of the box
The size is always the same
The perspective is always the same
The box is always completely within the field of fiew
The box is not rotated
Use a few scan lines across the image to find the transition from black background to box (in x and y)
Threshold exceeded, max gradient or whatever suits you best.
Discard outliers, use min and max coordinates to position the fixed size ROI over your box.
There are many other ways to find the center positon of that fixed ROI like
threshold, distance transform, maximum
or
threshold, blob search, centroid/contour
You could also do some contour matching.
I recommend you improve your setup so the background illumination does not exceed the box border (left/right is better than top/bottom). Then everything becomes easy.
Your edge image looks terrible btw. Check other methods or improve your Canny parameters.
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.