{
  "id": 177794,
  "title": "Lung segmentation issue for lighter images",
  "url": "/competitions/osic-pulmonary-fibrosis-progression/discussion/177794",
  "author_name": "",
  "post_date": "2020-08-27T11:38:28.147487900Z",
  "votes": 1,
  "comment_count": 2,
  "views": 0,
  "content": "<p>While performaing lung segmentation, I came across mainly 2 types of images:</p>\n<ol>\n<li><p><strong>Images with a darker shade</strong>: Majority of the images fall into this category. Many public kernels have extracted lung segments for these types of images. Below is a sample image which belongs to this category. <br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2568215%2F1bf54191fb7cb80f8d0e868d7371a934%2FScreenshot%202020-08-27%20at%204.44.33%20PM.png?generation=1598527233198133&amp;alt=media\" alt=\"\"></p></li>\n<li><p><strong>Images with thick grey borders and light shade</strong>:  For these types of images lung segmentation is a challenge as the lung region is a lot lighter than the first type of image(mentioned in Point-1). Below is a sample image which belongs to this category. On the left is the original image and on the right is the cropped version.</p></li>\n</ol>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2568215%2Fef9c3c1c694f3bd0952e18d16f28b73b%2FScreenshot%202020-08-27%20at%204.43.16%20PM.png?generation=1598526984290541&amp;alt=media\" alt=\"\"></p>\n<p>Any tips on how to extract lung region from the images in Point-2? Is this being discussed in any discussion post or is there a public notebook available for segmenting images in Point-2?</p>\n<p>The above images have been taken from <a href=\"https://www.kaggle.com/currypurin/osic-image-shape-eda-and-preprocess/data\" target=\"_blank\">this</a> notebook.</p>",
  "messages": [
    {
      "id": "987602",
      "postDate": "08/27/2020 11:38:28",
      "content": "<p>While performaing lung segmentation, I came across mainly 2 types of images:</p>\n<ol>\n<li><p><strong>Images with a darker shade</strong>: Majority of the images fall into this category. Many public kernels have extracted lung segments for these types of images. Below is a sample image which belongs to this category. <br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2568215%2F1bf54191fb7cb80f8d0e868d7371a934%2FScreenshot%202020-08-27%20at%204.44.33%20PM.png?generation=1598527233198133&amp;alt=media\" alt=\"\"></p></li>\n<li><p><strong>Images with thick grey borders and light shade</strong>:  For these types of images lung segmentation is a challenge as the lung region is a lot lighter than the first type of image(mentioned in Point-1). Below is a sample image which belongs to this category. On the left is the original image and on the right is the cropped version.</p></li>\n</ol>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2568215%2Fef9c3c1c694f3bd0952e18d16f28b73b%2FScreenshot%202020-08-27%20at%204.43.16%20PM.png?generation=1598526984290541&amp;alt=media\" alt=\"\"></p>\n<p>Any tips on how to extract lung region from the images in Point-2? Is this being discussed in any discussion post or is there a public notebook available for segmenting images in Point-2?</p>\n<p>The above images have been taken from <a href=\"https://www.kaggle.com/currypurin/osic-image-shape-eda-and-preprocess/data\" target=\"_blank\">this</a> notebook.</p>",
      "rawMarkdown": "While performaing lung segmentation, I came across mainly 2 types of images:\n1. **Images with a darker shade**: Majority of the images fall into this category. Many public kernels have extracted lung segments for these types of images. Below is a sample image which belongs to this category. \n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2568215%2F1bf54191fb7cb80f8d0e868d7371a934%2FScreenshot%202020-08-27%20at%204.44.33%20PM.png?generation=1598527233198133&alt=media)\n\n2. **Images with thick grey borders and light shade**:  For these types of images lung segmentation is a challenge as the lung region is a lot lighter than the first type of image(mentioned in Point-1). Below is a sample image which belongs to this category. On the left is the original image and on the right is the cropped version.\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2568215%2Fef9c3c1c694f3bd0952e18d16f28b73b%2FScreenshot%202020-08-27%20at%204.43.16%20PM.png?generation=1598526984290541&alt=media)\n\nAny tips on how to extract lung region from the images in Point-2? Is this being discussed in any discussion post or is there a public notebook available for segmenting images in Point-2?\n\nThe above images have been taken from [this] (https://www.kaggle.com/currypurin/osic-image-shape-eda-and-preprocess/data) notebook.",
      "votes": null
    },
    {
      "id": "987931",
      "postDate": "08/27/2020 16:16:31",
      "content": "<p>Thanks <a href=\"https://www.kaggle.com/abhishekgbhat\" target=\"_blank\">@abhishekgbhat</a>  for this valuable  information.<br>\n<strong>Images of type 2</strong> can affect lung segmentation method on <br>\n<a href=\"https://www.kaggle.com/akhileshdkapse/lung-segmentation-2d-3d-techniques-osic\" target=\"_blank\">https://www.kaggle.com/akhileshdkapse/lung-segmentation-2d-3d-techniques-osic</a></p>",
      "rawMarkdown": "Thanks @abhishekgbhat  for this valuable  information.\n**Images of type 2** can affect lung segmentation method on \nhttps://www.kaggle.com/akhileshdkapse/lung-segmentation-2d-3d-techniques-osic",
      "votes": null
    },
    {
      "id": "989697",
      "postDate": "08/29/2020 03:58:58",
      "content": "<p>The type-2 images are surrounded by water according to HU values (the border is all 0).<br>\nAll you need to do is crop the image to remove that border.<br>\nE.g.<br>\n<code>if img[0, 0] == 0:</code><br>\n        <code>bounds = np.where(img != 0)</code><br>\n        <code>(x1,y1),(x2,y2) = (np.amin(bounds[0]), np.amin(bounds[1])), (np.amax(bounds[0]), np.amax(bounds[1]))</code><br>\n        <code>return img[x1:x2, y1:y2]</code></p>",
      "rawMarkdown": "The type-2 images are surrounded by water according to HU values (the border is all 0).\nAll you need to do is crop the image to remove that border.\nE.g.\n`if img[0, 0] == 0:`\n        `bounds = np.where(img != 0)`\n        `(x1,y1),(x2,y2) = (np.amin(bounds[0]), np.amin(bounds[1])), (np.amax(bounds[0]), np.amax(bounds[1]))`\n        `return img[x1:x2, y1:y2]`",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 987931,
      "author_name": "akhileshdkapse",
      "author_url": "",
      "post_date": "08/27/2020 16:16:31",
      "content": "<p>Thanks <a href=\"https://www.kaggle.com/abhishekgbhat\" target=\"_blank\">@abhishekgbhat</a>  for this valuable  information.<br>\n<strong>Images of type 2</strong> can affect lung segmentation method on <br>\n<a href=\"https://www.kaggle.com/akhileshdkapse/lung-segmentation-2d-3d-techniques-osic\" target=\"_blank\">https://www.kaggle.com/akhileshdkapse/lung-segmentation-2d-3d-techniques-osic</a></p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 989697,
      "author_name": "humphreymunn",
      "author_url": "",
      "post_date": "08/29/2020 03:58:58",
      "content": "<p>The type-2 images are surrounded by water according to HU values (the border is all 0).<br>\nAll you need to do is crop the image to remove that border.<br>\nE.g.<br>\n<code>if img[0, 0] == 0:</code><br>\n        <code>bounds = np.where(img != 0)</code><br>\n        <code>(x1,y1),(x2,y2) = (np.amin(bounds[0]), np.amin(bounds[1])), (np.amax(bounds[0]), np.amax(bounds[1]))</code><br>\n        <code>return img[x1:x2, y1:y2]</code></p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "987602": "While performaing lung segmentation, I came across mainly 2 types of images:\n1. **Images with a darker shade**: Majority of the images fall into this category. Many public kernels have extracted lung segments for these types of images. Below is a sample image which belongs to this category. \n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2568215%2F1bf54191fb7cb80f8d0e868d7371a934%2FScreenshot%202020-08-27%20at%204.44.33%20PM.png?generation=1598527233198133&alt=media)\n\n2. **Images with thick grey borders and light shade**:  For these types of images lung segmentation is a challenge as the lung region is a lot lighter than the first type of image(mentioned in Point-1). Below is a sample image which belongs to this category. On the left is the original image and on the right is the cropped version.\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2568215%2Fef9c3c1c694f3bd0952e18d16f28b73b%2FScreenshot%202020-08-27%20at%204.43.16%20PM.png?generation=1598526984290541&alt=media)\n\nAny tips on how to extract lung region from the images in Point-2? Is this being discussed in any discussion post or is there a public notebook available for segmenting images in Point-2?\n\nThe above images have been taken from [this] (https://www.kaggle.com/currypurin/osic-image-shape-eda-and-preprocess/data) notebook.",
    "987931": "Thanks @abhishekgbhat  for this valuable  information.\n**Images of type 2** can affect lung segmentation method on \nhttps://www.kaggle.com/akhileshdkapse/lung-segmentation-2d-3d-techniques-osic",
    "989697": "The type-2 images are surrounded by water according to HU values (the border is all 0).\nAll you need to do is crop the image to remove that border.\nE.g.\n`if img[0, 0] == 0:`\n        `bounds = np.where(img != 0)`\n        `(x1,y1),(x2,y2) = (np.amin(bounds[0]), np.amin(bounds[1])), (np.amax(bounds[0]), np.amax(bounds[1]))`\n        `return img[x1:x2, y1:y2]`"
  },
  "source": "meta"
}