{
  "id": 231381,
  "title": "No Color Preprocessing Performs Better than CLAHE, Gaussian, and Combination of CLAHE and Gaussian",
  "url": "/competitions/aptos2019-blindness-detection/discussion/231381",
  "author_name": "Ammar Chalifah",
  "post_date": "2021-04-08T10:15:40.671000",
  "votes": 1,
  "comment_count": 0,
  "views": 0,
  "content": "<p>I'm trying to compare EfficientNetB0 to B3's performances in classifying diabetic retinopathy (framed as a regression) by varying the image preprocessing strategy. My 4 strategy picks are crop-resize, crop-resize-CLAHE, crop-resize-Gaussian, and crop-resize-CLAHE-Gaussian.</p>\n<p>Here's the code:</p>\n<pre><code>def preprocess_image(image, sigmaX=10, **kwargs):\n    \"\"\"\n    The whole preprocessing pipeline\n\n    :param img: A NumPy Array that will be cropped\n    :param sigmaX: Value used for add GaussianBlur to the image\n\n    :return: A NumPy array containing the preprocessed image\n    \"\"\"\n    image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\n    image = crop_image_from_gray(image)\n    image = cv2.resize(image, (512, 512))\n    if kwargs['GAUSSIAN'] == True:\n      image = cv2.addWeighted(image,4, cv2.GaussianBlur(image, (0,0) ,sigmaX), -4, 128)\n    if kwargs['CLAHE'] == True:\n      lab = cv2.cvtColor(image, cv2.COLOR_RGB2LAB)\n      lab_planes = cv2.split(lab)\n      lab_planes[0] = clahe.apply(lab_planes[0])\n      lab = cv2.merge(lab_planes)\n      image = cv2.cvtColor(lab, cv2.COLOR_LAB2RGB)\n    if kwargs['BGR']:\n      image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)\n    return image\n</code></pre>\n<p>After comparing the performance using accuracy and quadratic weighted Kappa, the crop-resize (no color preprocessing) strategy outperforms the other quite significantly. Is this phenomenon expected or this finding is only a coincidence? Thanks</p>",
  "messages": [
    {
      "id": 1267095,
      "postDate": "2021-04-08T10:15:40.673Z",
      "content": "<p>I'm trying to compare EfficientNetB0 to B3's performances in classifying diabetic retinopathy (framed as a regression) by varying the image preprocessing strategy. My 4 strategy picks are crop-resize, crop-resize-CLAHE, crop-resize-Gaussian, and crop-resize-CLAHE-Gaussian.</p>\n<p>Here's the code:</p>\n<pre><code>def preprocess_image(image, sigmaX=10, **kwargs):\n    \"\"\"\n    The whole preprocessing pipeline\n\n    :param img: A NumPy Array that will be cropped\n    :param sigmaX: Value used for add GaussianBlur to the image\n\n    :return: A NumPy array containing the preprocessed image\n    \"\"\"\n    image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\n    image = crop_image_from_gray(image)\n    image = cv2.resize(image, (512, 512))\n    if kwargs['GAUSSIAN'] == True:\n      image = cv2.addWeighted(image,4, cv2.GaussianBlur(image, (0,0) ,sigmaX), -4, 128)\n    if kwargs['CLAHE'] == True:\n      lab = cv2.cvtColor(image, cv2.COLOR_RGB2LAB)\n      lab_planes = cv2.split(lab)\n      lab_planes[0] = clahe.apply(lab_planes[0])\n      lab = cv2.merge(lab_planes)\n      image = cv2.cvtColor(lab, cv2.COLOR_LAB2RGB)\n    if kwargs['BGR']:\n      image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)\n    return image\n</code></pre>\n<p>After comparing the performance using accuracy and quadratic weighted Kappa, the crop-resize (no color preprocessing) strategy outperforms the other quite significantly. Is this phenomenon expected or this finding is only a coincidence? Thanks</p>",
      "rawMarkdown": "I'm trying to compare EfficientNetB0 to B3's performances in classifying diabetic retinopathy (framed as a regression) by varying the image preprocessing strategy. My 4 strategy picks are crop-resize, crop-resize-CLAHE, crop-resize-Gaussian, and crop-resize-CLAHE-Gaussian.\n\nHere's the code:\n```\ndef preprocess_image(image, sigmaX=10, **kwargs):\n    \"\"\"\n    The whole preprocessing pipeline\n    \n    :param img: A NumPy Array that will be cropped\n    :param sigmaX: Value used for add GaussianBlur to the image\n    \n    :return: A NumPy array containing the preprocessed image\n    \"\"\"\n    image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\n    image = crop_image_from_gray(image)\n    image = cv2.resize(image, (512, 512))\n    if kwargs['GAUSSIAN'] == True:\n      image = cv2.addWeighted(image,4, cv2.GaussianBlur(image, (0,0) ,sigmaX), -4, 128)\n    if kwargs['CLAHE'] == True:\n      lab = cv2.cvtColor(image, cv2.COLOR_RGB2LAB)\n      lab_planes = cv2.split(lab)\n      lab_planes[0] = clahe.apply(lab_planes[0])\n      lab = cv2.merge(lab_planes)\n      image = cv2.cvtColor(lab, cv2.COLOR_LAB2RGB)\n    if kwargs['BGR']:\n      image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)\n    return image\n```\n\nAfter comparing the performance using accuracy and quadratic weighted Kappa, the crop-resize (no color preprocessing) strategy outperforms the other quite significantly. Is this phenomenon expected or this finding is only a coincidence? Thanks",
      "votes": 1
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "1267095": "I'm trying to compare EfficientNetB0 to B3's performances in classifying diabetic retinopathy (framed as a regression) by varying the image preprocessing strategy. My 4 strategy picks are crop-resize, crop-resize-CLAHE, crop-resize-Gaussian, and crop-resize-CLAHE-Gaussian.\n\nHere's the code:\n```\ndef preprocess_image(image, sigmaX=10, **kwargs):\n    \"\"\"\n    The whole preprocessing pipeline\n    \n    :param img: A NumPy Array that will be cropped\n    :param sigmaX: Value used for add GaussianBlur to the image\n    \n    :return: A NumPy array containing the preprocessed image\n    \"\"\"\n    image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\n    image = crop_image_from_gray(image)\n    image = cv2.resize(image, (512, 512))\n    if kwargs['GAUSSIAN'] == True:\n      image = cv2.addWeighted(image,4, cv2.GaussianBlur(image, (0,0) ,sigmaX), -4, 128)\n    if kwargs['CLAHE'] == True:\n      lab = cv2.cvtColor(image, cv2.COLOR_RGB2LAB)\n      lab_planes = cv2.split(lab)\n      lab_planes[0] = clahe.apply(lab_planes[0])\n      lab = cv2.merge(lab_planes)\n      image = cv2.cvtColor(lab, cv2.COLOR_LAB2RGB)\n    if kwargs['BGR']:\n      image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)\n    return image\n```\n\nAfter comparing the performance using accuracy and quadratic weighted Kappa, the crop-resize (no color preprocessing) strategy outperforms the other quite significantly. Is this phenomenon expected or this finding is only a coincidence? Thanks"
  }
}