Python opencv aeroplane condensation trail detection - python

My task is to detect aeroplane condensation trails on the blue sky and deleting everything else from the picture, but I have to leave a 10-pixel wide area around the trails.
I have managed to draw the contours of the condensation trails based on colour using a mask and cv2.drawContours but I'm stuck with creating that 10-pixel sky blue area around it-basically I have to scale up the contour line.
Is it possible to scale up contours drawn by the cv2.drawContours command?

Since you already have a list of points on the contour, you can easily draw a 10-pixel thick line on it by using the line function between consecutive points (look at the thickness parameter). To fill the rest of the area inside the contour, look at the fillPoly function.

Related

How to fill in an area below detected contours in Python OpenCV?

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.

Count shaded and unshaded rectangles in an grid image with noise

I am trying to count all the shaded and un-shaded rectangles in this grid using python. I tried contour detection in OpenCV and was not able to achieve this. I also tried the hough line transform and detected the lines in the image, but I am not able to figure out how to proceed further. Is there a better way of doing it? Can someone suggest a way to proceed?
As your image looks very clean, I would
threshold the image to select white regions: gray regions and black lines will be black
use findContours() to count white blobs
do another threshold to select black lines. Only black lines will be black, everything else white
XOR the two images: this way you should have the gray regions
use findContours() to count the gray blobs
EDIT:
The ellipse cuts some rectangles and this will affect your count. If you want to remove it, the thresholds are not enough (both the ellipse and the rectangle lines are black). A possible way to do it:
With Hough Lines you can detect the lines,
draw in a new image the vertical and horizontal lines (ignore diagonal lines as they may be part od the ellipse)
with boolean operations (and, xor or or) between the thresholded images and the lines image you should be able to keep only the lines and remove the ellipse

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
)

scikit image contour completion

I am working with the following image.
My aim is to get the curvature of the outermost circle in the central part of the image.
AFTER CANNY EDGE FILITER
My focus is the concentric circles in the center of the image.
I need to be able to get the radius of curvature of the outermost circle.
I have tried find_contours, but it produces thousands of colored disconnected contours.
Regards,
Richard Madson

Detecting center of image from parabolic mirror?

I have a panoramic one shot lens from here: http://www.0-360.com/ and I wrote a script using the python image library to "unwrap" the image into a panorama. I want to automate this process though, as currently I have to specify the center of the image. Also, getting the radius of the circle would be good too. The input image looks like this:
And the "unwrapped" image looks like this:
So far I have been trying the Hough Circle detection. The issues I have is selecting the correct values to use. Also, sometimes, dark objects near the center circle seem to throw it off.
Other Ideas I had:
Hough Line detection of the unwrapped image. Basically, choose center pixel as center, then unwrap and see if the lines on the top and bottom are straight or "curvy". If not straight, then keep trying with different centers.
Moments/blob detection. Maybe I can find the center blob and find the center of that. The problem is sometimes I get a bright ring in the center of the dark disk as seen in the image above. Also, the issue with dark objects near the center.
Paint the top bevel of the mirror a distinct color like green to make circle detection easier? If I use green and only use the green channel, would the detection be easier?
Whats the best method I should try and use to get the center of this image and possibly the radius of the outer and inner rings.
As your image have multiple circle with common centre you can move that way, like
Detect circle with Hough circle and consider circle with common centre.
Now check the ratio for co-centred circle, as your image keep that ratio constant.
I guess don't make it too fancy. The black center is at the center of the image, right? Cut a square ROI close to the image center and look for 'black' region there. Store all the 'black' pixel locations and find their center. You may consider using CMYK color space for detecting the black region.

Categories

Resources