# February 24, 2020 - Testing out Distance threshold & Separating contour through nearby points

### Lab Work

Today, I continued to try and figure out how to segment the contour around the eggs in this image (green contour on left side of image): To figure out how to measure each of the eggs separately.

Last week, I thought of a possible method to split the contour:

1. find the convexhull for the contour of interest
2. find the convexity defects for the contour of interest
3. make a distance threshold between the convexhull and convexity defects points
4. make a distance threshold between the convexity defects themselves
5. make a bounding box/ellipse around the contour of interest
6. find angle of the bounding box/ellipse
• if the angle of two convexity defect points within a certain distance threshold is within a certain range, then connect those points.
• for clusters that go all the way around in a circle, find angle range between horizontal and vertical axes

In order to test if this would be a viable way to split the contour, I started by trying to visualize all of the distances between the convexhull points and the convexity defect points, which resulted in this image: After looking at this image, I realized that it might be very difficult to create a distance threshold, so I would probably have to try and find different ways to split the contour.

When looking at the image more, I realized that many of the convexity defect points are the innermost point of a contour in a local area, and so if a perpendicular line is made based off of the line that consists of the points that are immediately to the right and the left of the innermost point, then that could be a possible way to split the contour:

After using these equations and sources below:

1. Finding the index of a numpy array in a list
2. euclidean distance
3. midpoint formula
4. point slope equation
5. perpendicular line equation

This was the output: This seems like a good start to figuring out how to split the contour, so I think that I will try and continue to improve this method and see if a promising result turns out.

### Next Steps

Continue to try and improve current method being used to split the contour

Written on February 24, 2020
{"ft_lang_label":"__label__en","ft_lang_prob":0.9460651,"math_prob":0.94101965,"size":2185,"snap":"2020-34-2020-40","text_gpt3_token_len":456,"char_repetition_ratio":0.15818432,"word_repetition_ratio":0.033505153,"special_character_ratio":0.20091534,"punctuation_ratio":0.05721393,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97305936,"pos_list":[0,1,2,3,4,5,6],"im_url_duplicate_count":[null,2,null,2,null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-09-29T23:52:01Z\",\"WARC-Record-ID\":\"<urn:uuid:4a35d679-1de8-495b-8774-20453fd76b45>\",\"Content-Length\":\"7567\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b1cab5c1-1fe9-430a-99c0-36dc6bcd6b90>\",\"WARC-Concurrent-To\":\"<urn:uuid:69980ef5-329e-4d71-b8ed-89fb66c60620>\",\"WARC-IP-Address\":\"185.199.111.153\",\"WARC-Target-URI\":\"https://h-ra.github.io/32-DistanceThreshold&NearbyPts/\",\"WARC-Payload-Digest\":\"sha1:2XQ6NVKUW7ZWKYVRTBTBJZSPVSAUMTTZ\",\"WARC-Block-Digest\":\"sha1:6NSUPXK3NL7VT57IA5NUNDZNBGZ5CGHQ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-40/CC-MAIN-2020-40_segments_1600402093104.90_warc_CC-MAIN-20200929221433-20200930011433-00021.warc.gz\"}"}