{
  "id": 30840,
  "title": "Coordinates from label dots",
  "url": "/competitions/noaa-fisheries-steller-sea-lion-population-count/discussion/30840",
  "author_name": "",
  "post_date": "2017-03-29T17:20:51.863156200Z",
  "votes": 1,
  "comment_count": 1,
  "views": 0,
  "content": "<p>Has anyone tried to find the coordinates of the sea lions from the dotted images? I think making labels with coordinates would be quite useful.</p>\n\n<p>I tried a few simple approaches, but none seem to give good results. Has anyone had better luck?</p>\n\n<p>What I tried:</p>\n\n<ul>\n<li><a href=\"http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_imgproc/py_houghcircles/py_houghcircles.html\">Hough Circles</a> on a grayscale image. If we can find the dots we can then get the colour of the centre of the circle and match it with the closest from the labels (green, red, brown, etc.). However this method seems only to give a lot of noise...</li>\n</ul>\n\n<p><img src=\"http://vlad.wtf/assets/kg/circles.png\" alt=\"circles\" title=\"\"></p>\n\n<ul>\n<li><a href=\"http://docs.opencv.org/3.2.0/d4/dc6/tutorial_py_template_matching.html\">Template matching</a>. I manually took one of the dots and made a 7x7px template. Then applied template matching. I tried both RGB (green dot) and grayscale.</li>\n</ul>\n\n<p>Template: <img src=\"http://vlad.wtf/assets/kg/greendot.png\" alt=\"template\" title=\"\"></p>\n\n<p>RGB:\n <img src=\"http://vlad.wtf/assets/kg/templatergb.png\" alt=\"rgb template matching\" title=\"\"></p>\n\n<p>Grayscale:\n <img src=\"http://vlad.wtf/assets/kg/template.png\" alt=\"grayscale template matching\" title=\"\"></p>\n\n<ul>\n<li>Also tried colour tresholding. I picked some colour values for each dot colour, and applied thresholding on the image. I used HSV colour space and then manually adjusted the colour upper/lower bounds for the threshold, but I didn't lead to anything useful.</li>\n</ul>\n\n<p>RGB template matching is the best I have so far, but it's still performing very poorly. I'd be curious on what other approaches are there to try or if anyone had more success?</p>\n\n<p><strong>UPDATE:</strong> From looking at the <a href=\"https://www.kaggle.com/the1owl/noaa-fisheries-steller-sea-lion-population-count/finding-gerald\">Finding Gerald kernel</a> I tried to subtract the dotted and non dotted images and finally got this:</p>\n\n<pre><code>result = cv2.addWeighted(dotted,1,-simple,1,0)\n</code></pre>\n\n<p><img src=\"http://vlad.wtf/assets/kg/diff.png\" alt=\"subtract\" title=\"\"></p>\n\n<p>I will look into getting the coordinates and labels out of this image soon.</p>",
  "messages": [
    {
      "id": "171372",
      "postDate": "03/29/2017 17:20:51",
      "content": "<p>Has anyone tried to find the coordinates of the sea lions from the dotted images? I think making labels with coordinates would be quite useful.</p>\n\n<p>I tried a few simple approaches, but none seem to give good results. Has anyone had better luck?</p>\n\n<p>What I tried:</p>\n\n<ul>\n<li><a href=\"http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_imgproc/py_houghcircles/py_houghcircles.html\">Hough Circles</a> on a grayscale image. If we can find the dots we can then get the colour of the centre of the circle and match it with the closest from the labels (green, red, brown, etc.). However this method seems only to give a lot of noise...</li>\n</ul>\n\n<p><img src=\"http://vlad.wtf/assets/kg/circles.png\" alt=\"circles\" title=\"\"></p>\n\n<ul>\n<li><a href=\"http://docs.opencv.org/3.2.0/d4/dc6/tutorial_py_template_matching.html\">Template matching</a>. I manually took one of the dots and made a 7x7px template. Then applied template matching. I tried both RGB (green dot) and grayscale.</li>\n</ul>\n\n<p>Template: <img src=\"http://vlad.wtf/assets/kg/greendot.png\" alt=\"template\" title=\"\"></p>\n\n<p>RGB:\n <img src=\"http://vlad.wtf/assets/kg/templatergb.png\" alt=\"rgb template matching\" title=\"\"></p>\n\n<p>Grayscale:\n <img src=\"http://vlad.wtf/assets/kg/template.png\" alt=\"grayscale template matching\" title=\"\"></p>\n\n<ul>\n<li>Also tried colour tresholding. I picked some colour values for each dot colour, and applied thresholding on the image. I used HSV colour space and then manually adjusted the colour upper/lower bounds for the threshold, but I didn't lead to anything useful.</li>\n</ul>\n\n<p>RGB template matching is the best I have so far, but it's still performing very poorly. I'd be curious on what other approaches are there to try or if anyone had more success?</p>\n\n<p><strong>UPDATE:</strong> From looking at the <a href=\"https://www.kaggle.com/the1owl/noaa-fisheries-steller-sea-lion-population-count/finding-gerald\">Finding Gerald kernel</a> I tried to subtract the dotted and non dotted images and finally got this:</p>\n\n<pre><code>result = cv2.addWeighted(dotted,1,-simple,1,0)\n</code></pre>\n\n<p><img src=\"http://vlad.wtf/assets/kg/diff.png\" alt=\"subtract\" title=\"\"></p>\n\n<p>I will look into getting the coordinates and labels out of this image soon.</p>",
      "rawMarkdown": "Has anyone tried to find the coordinates of the sea lions from the dotted images? I think making labels with coordinates would be quite useful.\n\nI tried a few simple approaches, but none seem to give good results. Has anyone had better luck?\n\nWhat I tried:\n\n- [Hough Circles][1] on a grayscale image. If we can find the dots we can then get the colour of the centre of the circle and match it with the closest from the labels (green, red, brown, etc.). However this method seems only to give a lot of noise...\n\n![circles](http://vlad.wtf/assets/kg/circles.png)\n\n- [Template matching][2]. I manually took one of the dots and made a 7x7px template. Then applied template matching. I tried both RGB (green dot) and grayscale.\n\nTemplate: ![template](http://vlad.wtf/assets/kg/greendot.png)\n\nRGB:\n ![rgb template matching](http://vlad.wtf/assets/kg/templatergb.png)\n\nGrayscale:\n ![grayscale template matching](http://vlad.wtf/assets/kg/template.png)\n\n- Also tried colour tresholding. I picked some colour values for each dot colour, and applied thresholding on the image. I used HSV colour space and then manually adjusted the colour upper/lower bounds for the threshold, but I didn't lead to anything useful.\n\nRGB template matching is the best I have so far, but it's still performing very poorly. I'd be curious on what other approaches are there to try or if anyone had more success?\n\n**UPDATE:** From looking at the [Finding Gerald kernel][3] I tried to subtract the dotted and non dotted images and finally got this:\n\n    result = cv2.addWeighted(dotted,1,-simple,1,0)\n\n![subtract](http://vlad.wtf/assets/kg/diff.png)\n\nI will look into getting the coordinates and labels out of this image soon.\n\n\n  [1]: http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_imgproc/py_houghcircles/py_houghcircles.html\n  [2]: http://docs.opencv.org/3.2.0/d4/dc6/tutorial_py_template_matching.html\n  [3]: https://www.kaggle.com/the1owl/noaa-fisheries-steller-sea-lion-population-count/finding-gerald",
      "votes": null
    },
    {
      "id": "2327936",
      "postDate": "07/03/2023 08:54:30",
      "content": "<p>template matching using SAM model : <a href=\"https://youtu.be/ufoithWSv4U\" target=\"_blank\">https://youtu.be/ufoithWSv4U</a></p>",
      "rawMarkdown": "template matching using SAM model : https://youtu.be/ufoithWSv4U",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2327936,
      "author_name": "bemorekgg",
      "author_url": "",
      "post_date": "07/03/2023 08:54:30",
      "content": "<p>template matching using SAM model : <a href=\"https://youtu.be/ufoithWSv4U\" target=\"_blank\">https://youtu.be/ufoithWSv4U</a></p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "171372": "Has anyone tried to find the coordinates of the sea lions from the dotted images? I think making labels with coordinates would be quite useful.\n\nI tried a few simple approaches, but none seem to give good results. Has anyone had better luck?\n\nWhat I tried:\n\n- [Hough Circles][1] on a grayscale image. If we can find the dots we can then get the colour of the centre of the circle and match it with the closest from the labels (green, red, brown, etc.). However this method seems only to give a lot of noise...\n\n![circles](http://vlad.wtf/assets/kg/circles.png)\n\n- [Template matching][2]. I manually took one of the dots and made a 7x7px template. Then applied template matching. I tried both RGB (green dot) and grayscale.\n\nTemplate: ![template](http://vlad.wtf/assets/kg/greendot.png)\n\nRGB:\n ![rgb template matching](http://vlad.wtf/assets/kg/templatergb.png)\n\nGrayscale:\n ![grayscale template matching](http://vlad.wtf/assets/kg/template.png)\n\n- Also tried colour tresholding. I picked some colour values for each dot colour, and applied thresholding on the image. I used HSV colour space and then manually adjusted the colour upper/lower bounds for the threshold, but I didn't lead to anything useful.\n\nRGB template matching is the best I have so far, but it's still performing very poorly. I'd be curious on what other approaches are there to try or if anyone had more success?\n\n**UPDATE:** From looking at the [Finding Gerald kernel][3] I tried to subtract the dotted and non dotted images and finally got this:\n\n    result = cv2.addWeighted(dotted,1,-simple,1,0)\n\n![subtract](http://vlad.wtf/assets/kg/diff.png)\n\nI will look into getting the coordinates and labels out of this image soon.\n\n\n  [1]: http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_imgproc/py_houghcircles/py_houghcircles.html\n  [2]: http://docs.opencv.org/3.2.0/d4/dc6/tutorial_py_template_matching.html\n  [3]: https://www.kaggle.com/the1owl/noaa-fisheries-steller-sea-lion-population-count/finding-gerald",
    "2327936": "template matching using SAM model : https://youtu.be/ufoithWSv4U"
  },
  "source": "meta"
}