{
  "id": 162788,
  "title": "[Possible augmentation] Hair Removal from Images",
  "url": "/competitions/siim-isic-melanoma-classification/discussion/162788",
  "author_name": "",
  "post_date": "2020-06-30T03:44:52.920086Z",
  "votes": null,
  "comment_count": 1,
  "views": 0,
  "content": "<p>The augmentation introduced here:<a href=\"https://www.kaggle.com/c/siim-isic-melanoma-classification/discussion/159176\"> Advanced hair augmentation</a> adds extra pseudo hair to the images which is a neat idea, however, it may cause to covering up of the actual melanoma patch leading to a possible loss of information. I was wondering if there could be some sort of augmentation which could lead to the removal of hair in an image and being replaced by random-noise or average of the neighboring pixels.</p>\n\n<p>I got a basic removal algorithm to work using cv2 but am unsure about how to integrate it with the Data loader which is using tf.data.TFRecordDataset() and the augmentations are done using tf.image module. I was thinking that using cv2 would require some datatype conversions which would be at the expense of speed. I would love to know if this is a feasible augmentation to perform?</p>\n\n<p><code>\nkernel = np.ones((5,5),np.float32)/25\ndst = cv2.filter2D(img,-1,kernel)\nedges = cv2.Canny(dst,0,150)\nedges_new = np.stack([edges for _ in range(3)]).transpose(1,2,0)\n</code>\nOriginal Image:\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1464598%2Fb4f6b85c81774a104c65cc65d82f5299%2Ftemp2.jpg?generation=1593488425034278&amp;alt=media\" alt=\"\"></p>\n\n<p>Detected Hair:\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1464598%2F925fa9c7bdaff5c0561ad9efe52a6585%2Fhair_detected.jpg?generation=1593488464977499&amp;alt=media\" alt=\"\"></p>",
  "messages": [
    {
      "id": "907593",
      "postDate": "06/30/2020 03:44:52",
      "content": "<p>The augmentation introduced here:<a href=\"https://www.kaggle.com/c/siim-isic-melanoma-classification/discussion/159176\"> Advanced hair augmentation</a> adds extra pseudo hair to the images which is a neat idea, however, it may cause to covering up of the actual melanoma patch leading to a possible loss of information. I was wondering if there could be some sort of augmentation which could lead to the removal of hair in an image and being replaced by random-noise or average of the neighboring pixels.</p>\n\n<p>I got a basic removal algorithm to work using cv2 but am unsure about how to integrate it with the Data loader which is using tf.data.TFRecordDataset() and the augmentations are done using tf.image module. I was thinking that using cv2 would require some datatype conversions which would be at the expense of speed. I would love to know if this is a feasible augmentation to perform?</p>\n\n<p><code>\nkernel = np.ones((5,5),np.float32)/25\ndst = cv2.filter2D(img,-1,kernel)\nedges = cv2.Canny(dst,0,150)\nedges_new = np.stack([edges for _ in range(3)]).transpose(1,2,0)\n</code>\nOriginal Image:\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1464598%2Fb4f6b85c81774a104c65cc65d82f5299%2Ftemp2.jpg?generation=1593488425034278&amp;alt=media\" alt=\"\"></p>\n\n<p>Detected Hair:\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1464598%2F925fa9c7bdaff5c0561ad9efe52a6585%2Fhair_detected.jpg?generation=1593488464977499&amp;alt=media\" alt=\"\"></p>",
      "rawMarkdown": "The augmentation introduced here:[ Advanced hair augmentation](https://www.kaggle.com/c/siim-isic-melanoma-classification/discussion/159176) adds extra pseudo hair to the images which is a neat idea, however, it may cause to covering up of the actual melanoma patch leading to a possible loss of information. I was wondering if there could be some sort of augmentation which could lead to the removal of hair in an image and being replaced by random-noise or average of the neighboring pixels.\n\nI got a basic removal algorithm to work using cv2 but am unsure about how to integrate it with the Data loader which is using tf.data.TFRecordDataset() and the augmentations are done using tf.image module. I was thinking that using cv2 would require some datatype conversions which would be at the expense of speed. I would love to know if this is a feasible augmentation to perform?\n\n```\nkernel = np.ones((5,5),np.float32)/25\ndst = cv2.filter2D(img,-1,kernel)\nedges = cv2.Canny(dst,0,150)\nedges_new = np.stack([edges for _ in range(3)]).transpose(1,2,0)\n```\nOriginal Image:\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1464598%2Fb4f6b85c81774a104c65cc65d82f5299%2Ftemp2.jpg?generation=1593488425034278&amp;alt=media)\n\nDetected Hair:\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1464598%2F925fa9c7bdaff5c0561ad9efe52a6585%2Fhair_detected.jpg?generation=1593488464977499&amp;alt=media)",
      "votes": null
    },
    {
      "id": "907939",
      "postDate": "06/30/2020 09:11:51",
      "content": "<p>I created a hair removal that was very easy to add to a tensorflow script.  It adds a little improvement and does not seem expensive on my local dual GPU Ubuntu pc.  It used cv2 much like your process .  It did not completely remove hair but it also removes the mm grid seen on many images.   It’s on my todo to refine it enough to share.  </p>",
      "rawMarkdown": "I created a hair removal that was very easy to add to a tensorflow script.  It adds a little improvement and does not seem expensive on my local dual GPU Ubuntu pc.  It used cv2 much like your process .  It did not completely remove hair but it also removes the mm grid seen on many images.   It’s on my todo to refine it enough to share.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 907939,
      "author_name": "pcjimmmy",
      "author_url": "",
      "post_date": "06/30/2020 09:11:51",
      "content": "<p>I created a hair removal that was very easy to add to a tensorflow script.  It adds a little improvement and does not seem expensive on my local dual GPU Ubuntu pc.  It used cv2 much like your process .  It did not completely remove hair but it also removes the mm grid seen on many images.   It’s on my todo to refine it enough to share.  </p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "907593": "The augmentation introduced here:[ Advanced hair augmentation](https://www.kaggle.com/c/siim-isic-melanoma-classification/discussion/159176) adds extra pseudo hair to the images which is a neat idea, however, it may cause to covering up of the actual melanoma patch leading to a possible loss of information. I was wondering if there could be some sort of augmentation which could lead to the removal of hair in an image and being replaced by random-noise or average of the neighboring pixels.\n\nI got a basic removal algorithm to work using cv2 but am unsure about how to integrate it with the Data loader which is using tf.data.TFRecordDataset() and the augmentations are done using tf.image module. I was thinking that using cv2 would require some datatype conversions which would be at the expense of speed. I would love to know if this is a feasible augmentation to perform?\n\n```\nkernel = np.ones((5,5),np.float32)/25\ndst = cv2.filter2D(img,-1,kernel)\nedges = cv2.Canny(dst,0,150)\nedges_new = np.stack([edges for _ in range(3)]).transpose(1,2,0)\n```\nOriginal Image:\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1464598%2Fb4f6b85c81774a104c65cc65d82f5299%2Ftemp2.jpg?generation=1593488425034278&amp;alt=media)\n\nDetected Hair:\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1464598%2F925fa9c7bdaff5c0561ad9efe52a6585%2Fhair_detected.jpg?generation=1593488464977499&amp;alt=media)",
    "907939": "I created a hair removal that was very easy to add to a tensorflow script.  It adds a little improvement and does not seem expensive on my local dual GPU Ubuntu pc.  It used cv2 much like your process .  It did not completely remove hair but it also removes the mm grid seen on many images.   It’s on my todo to refine it enough to share."
  },
  "source": "meta"
}