{
  "id": 271188,
  "title": "How can I include only relevant images in my Data?",
  "url": "/competitions/rsna-miccai-brain-tumor-radiogenomic-classification/discussion/271188",
  "author_name": "",
  "post_date": "2021-09-09T03:45:05.723193600Z",
  "votes": 2,
  "comment_count": 5,
  "views": 0,
  "content": "<p>Hello guys, I was wondering how I could only include relevant or \"proper\" images in my data. By \"proper\" I mean, images that properly show the brain. Some images only show either black screen or just a small part of the brain and not the entire brain. How can remove or exclude such images?</p>",
  "messages": [
    {
      "id": "1507272",
      "postDate": "09/09/2021 03:45:05",
      "content": "<p>Hello guys, I was wondering how I could only include relevant or \"proper\" images in my data. By \"proper\" I mean, images that properly show the brain. Some images only show either black screen or just a small part of the brain and not the entire brain. How can remove or exclude such images?</p>",
      "rawMarkdown": "Hello guys, I was wondering how I could only include relevant or \"proper\" images in my data. By \"proper\" I mean, images that properly show the brain. Some images only show either black screen or just a small part of the brain and not the entire brain. How can remove or exclude such images?",
      "votes": null
    },
    {
      "id": "1507340",
      "postDate": "09/09/2021 05:34:34",
      "content": "<p>Count the number of equal (black) pixels and withdraw those above a certain threshold.</p>",
      "rawMarkdown": "Count the number of equal (black) pixels and withdraw those above a certain threshold.",
      "votes": null
    },
    {
      "id": "1507350",
      "postDate": "09/09/2021 05:42:34",
      "content": "<p>Yeah, I am doing that. Actually, I am selecting an image from each of the distribution (T1w, T2w, T1wCE and FLAIR) and that image is like the \"ideal\" case for me and then I am summing all the pixels up and scaling it by 255. All the images that are near that threshold are selected others are discarded. Thank you for your input Alexander :D</p>",
      "rawMarkdown": "Yeah, I am doing that. Actually, I am selecting an image from each of the distribution (T1w, T2w, T1wCE and FLAIR) and that image is like the \"ideal\" case for me and then I am summing all the pixels up and scaling it by 255. All the images that are near that threshold are selected others are discarded. Thank you for your input Alexander :D",
      "votes": null
    },
    {
      "id": "1507358",
      "postDate": "09/09/2021 06:04:09",
      "content": "<p><a href=\"https://www.kaggle.com/eddwait\" target=\"_blank\">@eddwait</a>, glad it helped. I think it will work if the \"ideal\" images are uniform. But I can imagine cases when summing up ignores the wrong images, e.g. if parts of them are inverted. So if your first approach produces wrong results, try to count the predominant pixel(s) and divide it by the overall number (if image size alters). Pretty nice but likely unnecessary extensive would be to create a 'Gini index' of pixel variance.</p>",
      "rawMarkdown": "eddwait, glad it helped. I think it will work if the \"ideal\" images are uniform. But I can imagine cases when summing up ignores the wrong images, e.g. if parts of them are inverted. So if your first approach produces wrong results, try to count the predominant pixel(s) and divide it by the overall number (if image size alters). Pretty nice but likely unnecessary extensive would be to create a 'Gini index' of pixel variance.",
      "votes": null
    },
    {
      "id": "1509183",
      "postDate": "09/11/2021 01:39:29",
      "content": "<p>I'm using this to filter out the irrelevant images in my data.<br>\n<code>if (np.count_nonzero(img == 0) / img_size**2) &lt; threshold:</code> <br>\nso what it does is counts the number of zeros in the image and takes the ratio of zero_pixels and non_zero_pixels and filters them with a certain threshold.<br>\nI'm filtering them out after resizing them to the size 224x224. and a threshold of 0.9 seems to work fine for me. you can find something that looks better for you. </p>",
      "rawMarkdown": "I'm using this to filter out the irrelevant images in my data.\n`if (np.count_nonzero(img == 0) / img_size**2) < threshold:` \nso what it does is counts the number of zeros in the image and takes the ratio of zero_pixels and non_zero_pixels and filters them with a certain threshold.\nI'm filtering them out after resizing them to the size 224x224. and a threshold of 0.9 seems to work fine for me. you can find something that looks better for you.",
      "votes": null
    },
    {
      "id": "1509319",
      "postDate": "09/11/2021 06:11:13",
      "content": "<p>Thank you Rohan :D</p>",
      "rawMarkdown": "Thank you Rohan :D",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1507340,
      "author_name": "alexanderbader",
      "author_url": "",
      "post_date": "09/09/2021 05:34:34",
      "content": "<p>Count the number of equal (black) pixels and withdraw those above a certain threshold.</p>",
      "votes": null,
      "replies": [
        {
          "id": 1507350,
          "author_name": "eddwait",
          "author_url": "",
          "post_date": "09/09/2021 05:42:34",
          "content": "<p>Yeah, I am doing that. Actually, I am selecting an image from each of the distribution (T1w, T2w, T1wCE and FLAIR) and that image is like the \"ideal\" case for me and then I am summing all the pixels up and scaling it by 255. All the images that are near that threshold are selected others are discarded. Thank you for your input Alexander :D</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1507358,
          "author_name": "alexanderbader",
          "author_url": "",
          "post_date": "09/09/2021 06:04:09",
          "content": "<p><a href=\"https://www.kaggle.com/eddwait\" target=\"_blank\">@eddwait</a>, glad it helped. I think it will work if the \"ideal\" images are uniform. But I can imagine cases when summing up ignores the wrong images, e.g. if parts of them are inverted. So if your first approach produces wrong results, try to count the predominant pixel(s) and divide it by the overall number (if image size alters). Pretty nice but likely unnecessary extensive would be to create a 'Gini index' of pixel variance.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1509183,
      "author_name": "theunrealsamurai",
      "author_url": "",
      "post_date": "09/11/2021 01:39:29",
      "content": "<p>I'm using this to filter out the irrelevant images in my data.<br>\n<code>if (np.count_nonzero(img == 0) / img_size**2) &lt; threshold:</code> <br>\nso what it does is counts the number of zeros in the image and takes the ratio of zero_pixels and non_zero_pixels and filters them with a certain threshold.<br>\nI'm filtering them out after resizing them to the size 224x224. and a threshold of 0.9 seems to work fine for me. you can find something that looks better for you. </p>",
      "votes": null,
      "replies": [
        {
          "id": 1509319,
          "author_name": "eddwait",
          "author_url": "",
          "post_date": "09/11/2021 06:11:13",
          "content": "<p>Thank you Rohan :D</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1507272": "Hello guys, I was wondering how I could only include relevant or \"proper\" images in my data. By \"proper\" I mean, images that properly show the brain. Some images only show either black screen or just a small part of the brain and not the entire brain. How can remove or exclude such images?",
    "1507340": "Count the number of equal (black) pixels and withdraw those above a certain threshold.",
    "1507350": "Yeah, I am doing that. Actually, I am selecting an image from each of the distribution (T1w, T2w, T1wCE and FLAIR) and that image is like the \"ideal\" case for me and then I am summing all the pixels up and scaling it by 255. All the images that are near that threshold are selected others are discarded. Thank you for your input Alexander :D",
    "1507358": "eddwait, glad it helped. I think it will work if the \"ideal\" images are uniform. But I can imagine cases when summing up ignores the wrong images, e.g. if parts of them are inverted. So if your first approach produces wrong results, try to count the predominant pixel(s) and divide it by the overall number (if image size alters). Pretty nice but likely unnecessary extensive would be to create a 'Gini index' of pixel variance.",
    "1509183": "I'm using this to filter out the irrelevant images in my data.\n`if (np.count_nonzero(img == 0) / img_size**2) < threshold:` \nso what it does is counts the number of zeros in the image and takes the ratio of zero_pixels and non_zero_pixels and filters them with a certain threshold.\nI'm filtering them out after resizing them to the size 224x224. and a threshold of 0.9 seems to work fine for me. you can find something that looks better for you.",
    "1509319": "Thank you Rohan :D"
  },
  "source": "meta"
}