Skip to content
Snippets Groups Projects
Commit 77b9503c authored by Albert Mitjans I Coma's avatar Albert Mitjans I Coma
Browse files

Only use region of interest in detect_ion_cloud()

parent e9f65e2c
No related branches found
No related tags found
No related merge requests found
......@@ -200,12 +200,13 @@ def detect_ion_cloud(image):
Measure the area of the biggest contour of the image. If it is larger than a certain threshold
consider an ion cloud.
"""
image = np.array(image)
region = settings.REGION # crop region of interest
image = np.array(image[region[0, 1]:region[1, 1], region[0, 0]:region[1, 0]])
image = gaussian(image, sigma=7)
_, binary = cv2.threshold(image, thresh=image.max()*0.8, maxval=255, type=cv2.THRESH_BINARY)
contours, _ = cv2.findContours(np.uint8(binary), cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
max_contour = max(contours, key=cv2.contourArea)
is_ion_cloud = bool(settings.AREA_THS < cv2.contourArea(max_contour) < np.size(image)/2)
is_ion_cloud = settings.AREA_THS < cv2.contourArea(max_contour) < np.size(image)/2
return is_ion_cloud
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment