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.
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 have a number of lobster images as shown in the photo. My goal is to identify the edge between the carapace and the body and its coordinates. However, it seems like the methods of finding contours based on HSV thresholds or Canny edge detection output didn't work well when I applied to these images.
My idea is to find a way to 'amplify' the color difference between two areas of an image to make it easier for finding mask/contours based on color threshold?
For example, if I can make the yellow of the edge in the image stronger, then I can easily find the mask of this area using color threshold, can we do that?
Thanks.
This color is closer to the rest of the picture than one think (in the HLS space).
IMO, the best way to enhance it is by means of the Euclidean distance to that particular orange in RGB space.
For instance, the pixels at distance 32√3:
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 am new to OpenCV. I am just wondering does OpenCV have function to find contours of same color pixels automatically. Currently, the only idea I can come up with is that do the binary transformation for certain color first, then use cv2.findContours(). Any better ideas?
Thank you.
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.