{
  "id": 290584,
  "title": "Fast underwater image enhancement for Improved Visual Perception [github+Paper]",
  "url": "/competitions/tensorflow-great-barrier-reef/discussion/290584",
  "author_name": "",
  "post_date": "2021-11-25T10:35:17.202286600Z",
  "votes": 89,
  "comment_count": 28,
  "views": 0,
  "content": "<p>Fast underwater image enhancement for Improved Visual Perception. #TensorFlow #PyTorch</p>\n<p><img src=\"https://i.postimg.cc/RCL27DtC/underwater.jpg\" alt=\"\"></p>\n<p><img src=\"https://i.postimg.cc/wv8xKmfq/funie.jpg\" alt=\"\"></p>\n<p><img src=\"https://i.postimg.cc/02J22v3X/Qualitative-performance-comparison.jpg\" alt=\"\"></p>\n<p>Paper: <a href=\"https://ieeexplore.ieee.org/document/9001231\" target=\"_blank\">https://ieeexplore.ieee.org/document/9001231</a><br>\nPreprint: <a href=\"https://arxiv.org/pdf/1903.09766.pdf\" target=\"_blank\">https://arxiv.org/pdf/1903.09766.pdf</a><br>\nDatasets: <a href=\"http://irvlab.cs.umn.edu/resources/euvp-dataset\" target=\"_blank\">http://irvlab.cs.umn.edu/resources/euvp-dataset</a><br>\nGithub: <a href=\"https://github.com/xahidbuffon/FUnIE-GAN\" target=\"_blank\">https://github.com/xahidbuffon/FUnIE-GAN</a></p>",
  "messages": [
    {
      "id": "1595024",
      "postDate": "11/25/2021 10:35:17",
      "content": "<p>Fast underwater image enhancement for Improved Visual Perception. #TensorFlow #PyTorch</p>\n<p><img src=\"https://i.postimg.cc/RCL27DtC/underwater.jpg\" alt=\"\"></p>\n<p><img src=\"https://i.postimg.cc/wv8xKmfq/funie.jpg\" alt=\"\"></p>\n<p><img src=\"https://i.postimg.cc/02J22v3X/Qualitative-performance-comparison.jpg\" alt=\"\"></p>\n<p>Paper: <a href=\"https://ieeexplore.ieee.org/document/9001231\" target=\"_blank\">https://ieeexplore.ieee.org/document/9001231</a><br>\nPreprint: <a href=\"https://arxiv.org/pdf/1903.09766.pdf\" target=\"_blank\">https://arxiv.org/pdf/1903.09766.pdf</a><br>\nDatasets: <a href=\"http://irvlab.cs.umn.edu/resources/euvp-dataset\" target=\"_blank\">http://irvlab.cs.umn.edu/resources/euvp-dataset</a><br>\nGithub: <a href=\"https://github.com/xahidbuffon/FUnIE-GAN\" target=\"_blank\">https://github.com/xahidbuffon/FUnIE-GAN</a></p>",
      "rawMarkdown": "Fast underwater image enhancement for Improved Visual Perception. #TensorFlow #PyTorch\n\n\n![](https://i.postimg.cc/RCL27DtC/underwater.jpg)\n\n\n![](https://i.postimg.cc/wv8xKmfq/funie.jpg)\n\n\n![](https://i.postimg.cc/02J22v3X/Qualitative-performance-comparison.jpg)\n\n\n\n\n\nPaper: https://ieeexplore.ieee.org/document/9001231\nPreprint: https://arxiv.org/pdf/1903.09766.pdf\nDatasets: http://irvlab.cs.umn.edu/resources/euvp-dataset\nGithub: https://github.com/xahidbuffon/FUnIE-GAN",
      "votes": null
    },
    {
      "id": "1595827",
      "postDate": "11/26/2021 02:56:27",
      "content": "<p>so I think this is for humans to be able to see things better. Neural networks shouldn't mind about underwater murkiness</p>",
      "rawMarkdown": "so I think this is for humans to be able to see things better. Neural networks shouldn't mind about underwater murkiness",
      "votes": null
    },
    {
      "id": "1596078",
      "postDate": "11/26/2021 07:20:53",
      "content": "<p>How can it help in this problem ??</p>",
      "rawMarkdown": "How can it help in this problem ??",
      "votes": null
    },
    {
      "id": "1596490",
      "postDate": "11/26/2021 14:44:29",
      "content": "<p>With limited data it can be helpful to normalize the images to the same color space. Under water there is also a quick visibility falloff which can make things more difficult for the neural network. In the worst case it could be used to augment the training dataset.</p>",
      "rawMarkdown": "With limited data it can be helpful to normalize the images to the same color space. Under water there is also a quick visibility falloff which can make things more difficult for the neural network. In the worst case it could be used to augment the training dataset.",
      "votes": null
    },
    {
      "id": "1597488",
      "postDate": "11/27/2021 14:54:28",
      "content": "<p>Nice topic <a href=\"https://www.kaggle.com/faisalalsrheed\" target=\"_blank\">@faisalalsrheed</a>, I was also thinking about reducing the blurry ness from the images and enhancing a bit, I tried with <code>CLAHE</code> and it is giving this result. I dont know this is good enough or not. Maybe further improvement can yield better results.  <em><code>From the image, it seems like all the rocks, plants, and other underwater objects are on the ground and sunlight falling upon them, not inside a sea.</code></em></p>\n<p>\n<img src=\"https://i.imgur.com/ZvlbMoH.png\">\n</p>\n<ul>\n<li>this is a sample result from Histogram Equalizer,</li>\n</ul>\n<p>\n<img src=\"https://i.imgur.com/SYwHWhQ.png\">\n</p>\n<p><code>source:</code>  <a href=\"https://www.kaggle.com/c/tensorflow-great-barrier-reef/discussion/291063\" target=\"_blank\">8 Methods on Underwater Image Enhancement and Color Restoration, With Code</a></p>",
      "rawMarkdown": "Nice topic @faisalalsrheed, I was also thinking about reducing the blurry ness from the images and enhancing a bit, I tried with `CLAHE` and it is giving this result. I dont know this is good enough or not. Maybe further improvement can yield better results.  *`From the image, it seems like all the rocks, plants, and other underwater objects are on the ground and sunlight falling upon them, not inside a sea.`*\n\n<p align=\"center\">\n<img width=\"900\" src=\"https://i.imgur.com/ZvlbMoH.png\">\n</p>\n\n- this is a sample result from Histogram Equalizer,\n\n<p align=\"center\">\n<img width=\"900\" src=\"https://i.imgur.com/SYwHWhQ.png\">\n</p>\n`source:`  [8 Methods on Underwater Image Enhancement and Color Restoration, With Code](https://www.kaggle.com/c/tensorflow-great-barrier-reef/discussion/291063)",
      "votes": null
    },
    {
      "id": "1597508",
      "postDate": "11/27/2021 15:18:34",
      "content": "<p><code>CLAHE</code> is well known for Image enhancement on digital x-ray images.</p>",
      "rawMarkdown": "`CLAHE ` is well known for Image enhancement on digital x-ray images.",
      "votes": null
    },
    {
      "id": "1597514",
      "postDate": "11/27/2021 15:24:56",
      "content": "<p>I did not know that before. Just got to know about this while browsing through some github repos,</p>\n<ul>\n<li><a href=\"https://github.com/asalmada/x-ray-images-enhancement\" target=\"_blank\">x ray images enhancement</a></li>\n</ul>",
      "rawMarkdown": "I did not know that before. Just got to know about this while browsing through some github repos,\n- [x ray images enhancement](https://github.com/asalmada/x-ray-images-enhancement)",
      "votes": null
    },
    {
      "id": "1597517",
      "postDate": "11/27/2021 15:29:49",
      "content": "<p>Just like any other neural network project, There is only one way to know……..to try it :)</p>",
      "rawMarkdown": "Just like any other neural network project, There is only one way to know........to try it :)",
      "votes": null
    },
    {
      "id": "1597525",
      "postDate": "11/27/2021 15:49:37",
      "content": "<p><img src=\"https://i.postimg.cc/PqwNSnMv/Object.jpg\" alt=\"\"></p>\n<p><strong>Reference</strong>: <a href=\"https://www.hindawi.com/journals/js/2020/6707328/\" target=\"_blank\">https://www.hindawi.com/journals/js/2020/6707328/</a></p>",
      "rawMarkdown": "![](https://i.postimg.cc/PqwNSnMv/Object.jpg)\n\n**Reference**: https://www.hindawi.com/journals/js/2020/6707328/",
      "votes": null
    },
    {
      "id": "1597549",
      "postDate": "11/27/2021 16:18:57",
      "content": "<p>This is wow :) Augmentation is the key </p>",
      "rawMarkdown": "This is wow :) Augmentation is the key",
      "votes": null
    },
    {
      "id": "1597688",
      "postDate": "11/27/2021 19:25:19",
      "content": "<p>If I read the paper correctly, they <em>start</em> with object detection and try to create areas of high salience, to which they apply channel manipulation to shift the color. If I'm correct, the techniques in this paper wouldn't be very helpful to this challenge. A general technique such as Sea-Thru (<a href=\"https://openaccess.thecvf.com/content_CVPR_2019/html/Akkaynak_Sea-Thru_A_Method_for_Removing_Water_From_Underwater_Images_CVPR_2019_paper.html\" target=\"_blank\">https://openaccess.thecvf.com/content_CVPR_2019/html/Akkaynak_Sea-Thru_A_Method_for_Removing_Water_From_Underwater_Images_CVPR_2019_paper.html</a>) would be very beneficial but:</p>\n<ul>\n<li>Sea-Thru requires a depth map; </li>\n<li>Sea-Thru's parameters are not published; and </li>\n<li>I believe it's patented.  </li>\n</ul>",
      "rawMarkdown": "If I read the paper correctly, they _start_ with object detection and try to create areas of high salience, to which they apply channel manipulation to shift the color. If I'm correct, the techniques in this paper wouldn't be very helpful to this challenge. A general technique such as Sea-Thru (https://openaccess.thecvf.com/content_CVPR_2019/html/Akkaynak_Sea-Thru_A_Method_for_Removing_Water_From_Underwater_Images_CVPR_2019_paper.html) would be very beneficial but:\n\n* Sea-Thru requires a depth map; \n* Sea-Thru's parameters are not published; and \n* I believe it's patented.",
      "votes": null
    },
    {
      "id": "1597701",
      "postDate": "11/27/2021 19:48:17",
      "content": "<p>Thank you for sharing about sea-thru </p>\n<p>wow<br>\n<img src=\"https://i.postimg.cc/6qpZCTFK/sea-thru3.jpg\" alt=\"\"><br>\n<img src=\"https://i.postimg.cc/MZ9Vqbjp/sea-thru1.jpg\" alt=\"\"><br>\n<img src=\"https://i.postimg.cc/FzCLpNQL/sea-thru2.jpg\" alt=\"\"></p>\n<p><strong>Reference:</strong> <a href=\"https://www.deryaakkaynak.com/sea-thru\" target=\"_blank\">https://www.deryaakkaynak.com/sea-thru</a></p>",
      "rawMarkdown": "Thank you for sharing about sea-thru \n\nwow\n![](https://i.postimg.cc/6qpZCTFK/sea-thru3.jpg)\n![](https://i.postimg.cc/MZ9Vqbjp/sea-thru1.jpg)\n![](https://i.postimg.cc/FzCLpNQL/sea-thru2.jpg)\n\n\n**Reference:** https://www.deryaakkaynak.com/sea-thru",
      "votes": null
    },
    {
      "id": "1599421",
      "postDate": "11/29/2021 12:27:17",
      "content": "<p>Sea-thru looks great but … it is not available so far. Second … it would be great to build model which is not only accurate but fast as well (second competition requirement). Putting sea-thru in data pipeline would slow down inference a lot in my opinion. </p>",
      "rawMarkdown": "Sea-thru looks great but ... it is not available so far. Second ... it would be great to build model which is not only accurate but fast as well (second competition requirement). Putting sea-thru in data pipeline would slow down inference a lot in my opinion.",
      "votes": null
    },
    {
      "id": "1599440",
      "postDate": "11/29/2021 12:46:58",
      "content": "<p>9 hours for the inference is plenty time to do things like applying not one but several models. Remember that you can use pretrained models. Some of the notebooks take 20 seconds to predict all test data during inference.</p>",
      "rawMarkdown": "9 hours for the inference is plenty time to do things like applying not one but several models. Remember that you can use pretrained models. Some of the notebooks take 20 seconds to predict all test data during inference.",
      "votes": null
    },
    {
      "id": "1599443",
      "postDate": "11/29/2021 12:50:38",
      "content": "<p>I am talking about this:</p>\n<blockquote>\n  <p>The TensorFlow team has been working closely with CSIRO and plans to use the winning solutions to create an on-device model for real-time detection of COTS. Additional prizes will be given to the fastest model using Tensorflow. </p>\n  <p>Achieve a private leaderboard score better than or equal to the private leaderboard score of the Top 10% of teams on the private leaderboard. For example, if there are 1000 teams, any selected submission with a score greater than the 100th place team's private score will be eligible.<br>\n      Use TensorFlow 2.X on GPU</p>\n</blockquote>\n<p>So if you want to be fast you shoud be as lightweight as possible …</p>",
      "rawMarkdown": "I am talking about this:\n> The TensorFlow team has been working closely with CSIRO and plans to use the winning solutions to create an on-device model for real-time detection of COTS. Additional prizes will be given to the fastest model using Tensorflow. \n\n> Achieve a private leaderboard score better than or equal to the private leaderboard score of the Top 10% of teams on the private leaderboard. For example, if there are 1000 teams, any selected submission with a score greater than the 100th place team's private score will be eligible.\n    Use TensorFlow 2.X on GPU\n\nSo if you want to be fast you shoud be as lightweight as possible ...",
      "votes": null
    },
    {
      "id": "1599540",
      "postDate": "11/29/2021 14:15:03",
      "content": "<p>Makes sense. Thank you for the clarification.</p>",
      "rawMarkdown": "Makes sense. Thank you for the clarification.",
      "votes": null
    },
    {
      "id": "1599544",
      "postDate": "11/29/2021 14:19:54",
      "content": "<p>No problem. Just this was my first move - to enhance photo quality … and then … realized (after reading competition rules) that coud be good direction but time consuming :) … </p>\n<p>P.S.<br>\nMiło widzieć :) Pozdrowienia!</p>",
      "rawMarkdown": "No problem. Just this was my first move - to enhance photo quality ... and then ... realized (after reading competition rules) that coud be good direction but time consuming :) ... \n\nP.S.\nMiło widzieć :) Pozdrowienia!",
      "votes": null
    },
    {
      "id": "1599835",
      "postDate": "11/29/2021 21:51:28",
      "content": "<p>For CLAHE, If you're using tensorflow, you can try </p>\n<pre><code>\n\n ():\n     ():\n        \n        im = tf.cast(im[..., c], tf.int32)\n        \n        histo = tf.histogram_fixed_width(im, [, ], nbins=)\n\n        \n        nonzero = tf.where(tf.not_equal(histo, ))\n        nonzero_histo = tf.reshape(tf.gather(histo, nonzero), [-])\n        step = (tf.reduce_sum(nonzero_histo) - nonzero_histo[-]) // \n\n         ():\n            \n            \n            lut = (tf.cumsum(histo) + (step // )) // step\n            \n            lut = tf.concat([[], lut[:-]], )\n            \n            \n             tf.clip_by_value(lut, , )\n\n        \n        \n        result = tf.cond(\n            tf.equal(step, ), : im,\n            : tf.gather(build_lut(histo, step), im))\n         tf.cast(result, tf.uint8)\n\n     mode == :\n        image = scale_channel(image, )\n         tf.cast(image, tf.float32)\n     mode == :\n        s1 = scale_channel(image, )\n        s2 = scale_channel(image, )\n        s3 = scale_channel(image, )\n        image = tf.stack([s1, s2, s3], -)\n         tf.cast(image, tf.float32)\n\n\n ():\n     IMAGE_SIZE != x.shape[]  IMAGE_SIZE != x.shape[]:\n        x_scale, y_scale = IMAGE_SIZE / x.shape[], IMAGE_SIZE / x.shape[]\n        y = y * [x_scale, y_scale, x_scale, y_scale, ]\n        x = tf.image.resize(x, [IMAGE_SIZE, IMAGE_SIZE])\n    x = equalize(x, mode=)\n    x = tf.divide(x, )\n     x, y\n</code></pre>\n<p>Sample output: </p>\n<p><img src=\"https://user-images.githubusercontent.com/17668390/143948453-96101885-42aa-4007-a9fc-9f1fa2ffb689.gif\" alt=\"Animation5\"></p>",
      "rawMarkdown": "For CLAHE, If you're using tensorflow, you can try \n\n```\n# https://github.com/tensorflow/models\n@tf.function\ndef equalize(image, mode='grayscale'):\n    def scale_channel(im, c):\n        \"\"\"Scale the data in the channel to implement equalize.\"\"\"\n        im = tf.cast(im[..., c], tf.int32)\n        # Compute the histogram of the image channel.\n        histo = tf.histogram_fixed_width(im, [0, 255], nbins=256)\n\n        # For the purposes of computing the step, filter out the nonzeros.\n        nonzero = tf.where(tf.not_equal(histo, 0))\n        nonzero_histo = tf.reshape(tf.gather(histo, nonzero), [-1])\n        step = (tf.reduce_sum(nonzero_histo) - nonzero_histo[-1]) // 255\n\n        def build_lut(histo, step):\n            # Compute the cumulative sum, shifting by step // 2\n            # and then normalization by step.\n            lut = (tf.cumsum(histo) + (step // 2)) // step\n            # Shift lut, prepending with 0.\n            lut = tf.concat([[0], lut[:-1]], 0)\n            # Clip the counts to be in range.  This is done\n            # in the C code for image.point.\n            return tf.clip_by_value(lut, 0, 255)\n\n        # If step is zero, return the original image.  Otherwise, build\n        # lut from the full histogram and step and then index from it.\n        result = tf.cond(\n            tf.equal(step, 0), lambda: im,\n            lambda: tf.gather(build_lut(histo, step), im))\n        return tf.cast(result, tf.uint8)\n\n    if mode == 'grayscale':\n        image = scale_channel(image, 0)\n        return tf.cast(image, tf.float32)\n    elif mode == 'rgb':\n        s1 = scale_channel(image, 0)\n        s2 = scale_channel(image, 1)\n        s3 = scale_channel(image, 2)\n        image = tf.stack([s1, s2, s3], -1)\n        return tf.cast(image, tf.float32)\n\n@tf.function\ndef rescale_input(x, y):\n    if IMAGE_SIZE != x.shape[2] or IMAGE_SIZE != x.shape[1]:\n        x_scale, y_scale = IMAGE_SIZE / x.shape[2], IMAGE_SIZE / x.shape[1]\n        y = y * [x_scale, y_scale, x_scale, y_scale, 1]\n        x = tf.image.resize(x, [IMAGE_SIZE, IMAGE_SIZE])\n    x = equalize(x, mode='rgb')\n    x = tf.divide(x, 255.)\n    return x, y\n```\n\nSample output: \n\n![Animation5](https://user-images.githubusercontent.com/17668390/143948453-96101885-42aa-4007-a9fc-9f1fa2ffb689.gif)",
      "votes": null
    },
    {
      "id": "1599839",
      "postDate": "11/29/2021 21:55:44",
      "content": "<p>Here are a few more results of it</p>\n<p><img src=\"https://user-images.githubusercontent.com/17668390/143948790-1a7a21f9-ef4c-4a86-a8ee-d44221255877.png\"> <img src=\"https://user-images.githubusercontent.com/17668390/143948795-d494307d-3fab-4eaa-a5ee-7db7950ce7ee.png\"> <img src=\"https://user-images.githubusercontent.com/17668390/143948804-30d7fcac-b695-4832-9fac-b9327e6f349a.png\"></p>",
      "rawMarkdown": "Here are a few more results of it\n\n<img src=\"https://user-images.githubusercontent.com/17668390/143948790-1a7a21f9-ef4c-4a86-a8ee-d44221255877.png\" width=\"200\" height=\"200\" /> <img src=\"https://user-images.githubusercontent.com/17668390/143948795-d494307d-3fab-4eaa-a5ee-7db7950ce7ee.png\" width=\"200\" height=\"200\" /> <img src=\"https://user-images.githubusercontent.com/17668390/143948804-30d7fcac-b695-4832-9fac-b9327e6f349a.png\" width=\"200\" height=\"200\" />",
      "votes": null
    },
    {
      "id": "1601031",
      "postDate": "12/01/2021 00:57:52",
      "content": "<p>Hi <a href=\"https://www.kaggle.com/ipythonx\" target=\"_blank\">@ipythonx</a>, I was trying your code, but the output image is not coming as yours, this is what I did,</p>\n<pre><code># reading an image using plt\nimg_plt = plt.imread('../input/tensorflow-great-barrier-reef/train_images/video_1/9101.jpg')\n\n# your function definition here\ndef equalize(image, mode='grayscale'):\n    ...\n    ...\n\n# calling your function\nx = equalize(img_plt, mode='rgb')\n# plotting that image,x\nplt.imshow(x.numpy())\n</code></pre>\n<p>This is the Output:</p>\n<p>\n<img src=\"https://i.imgur.com/cuZ6KPO.png\">\n</p>\n<p><code>Can you please help, mention any point that im missing. Thank you.</code> Is this because of using matplotlib for reading the image, I tried with cv2 for reading the image too, but the results were same.</p>",
      "rawMarkdown": "Hi @ipythonx, I was trying your code, but the output image is not coming as yours, this is what I did,\n```python\n# reading an image using plt\nimg_plt = plt.imread('../input/tensorflow-great-barrier-reef/train_images/video_1/9101.jpg')\n\n# your function definition here\ndef equalize(image, mode='grayscale'):\n    ...\n    ...\n\n# calling your function\nx = equalize(img_plt, mode='rgb')\n# plotting that image,x\nplt.imshow(x.numpy())\n```\n\nThis is the Output:\n<p align=\"center\">\n<img width=\"500\" src=\"https://i.imgur.com/cuZ6KPO.png\">\n</p>\n\n`Can you please help, mention any point that im missing. Thank you.` Is this because of using matplotlib for reading the image, I tried with cv2 for reading the image too, but the results were same.",
      "votes": null
    },
    {
      "id": "1601164",
      "postDate": "12/01/2021 04:34:31",
      "content": "<p>try </p>\n<pre><code>plt.imshow(x.numpy() / 255.)\n\nor \n\nplt.imshow(x.numpy().astype(np.uint8)\n</code></pre>",
      "rawMarkdown": "try \n\n```\nplt.imshow(x.numpy() / 255.)\n\nor \n\nplt.imshow(x.numpy().astype(np.uint8)\n```",
      "votes": null
    },
    {
      "id": "1601221",
      "postDate": "12/01/2021 05:17:21",
      "content": "<p>Thank you <a href=\"https://www.kaggle.com/ipythonx\" target=\"_blank\">@ipythonx</a> normalizing with 255. worked. I have read your code but I really don't understand the logic behind the code. can you please give some insights? I understand that you implemented <code>CLAHE</code>, but why not use any build-in like cv2 and stuff for <code>CLAHE</code>, how your <code>equalize</code> function is different from the build-in <code>CLAHE</code> function. cause build-in <code>CLAHE</code> looks like this,</p>\n<p>\n<img src=\"https://i.imgur.com/ZvlbMoH.png\">\n</p>",
      "rawMarkdown": "Thank you @ipythonx normalizing with 255. worked. I have read your code but I really don't understand the logic behind the code. can you please give some insights? I understand that you implemented `CLAHE`, but why not use any build-in like cv2 and stuff for `CLAHE`, how your `equalize` function is different from the build-in `CLAHE` function. cause build-in `CLAHE` looks like this,\n\n<p align=\"center\">\n<img width=\"900\" src=\"https://i.imgur.com/ZvlbMoH.png\">\n</p>",
      "votes": null
    },
    {
      "id": "1601386",
      "postDate": "12/01/2021 08:28:52",
      "content": "<p>The above equalize implementation is taken from <a href=\"https://github.com/tensorflow/models/blob/master/official/vision/image_classification/augment.py#L480\" target=\"_blank\">tensorflow/model</a>, which I think similar to <a href=\"https://www.tensorflow.org/addons/api_docs/python/tfa/image/equalize\" target=\"_blank\">tfa.image.equalize</a>; <a href=\"https://github.com/tensorflow/addons/pull/2362\" target=\"_blank\">discussion</a>. </p>",
      "rawMarkdown": "The above equalize implementation is taken from [tensorflow/model](https://github.com/tensorflow/models/blob/master/official/vision/image_classification/augment.py#L480), which I think similar to [tfa.image.equalize](https://www.tensorflow.org/addons/api_docs/python/tfa/image/equalize); [discussion](https://github.com/tensorflow/addons/pull/2362).",
      "votes": null
    },
    {
      "id": "1601406",
      "postDate": "12/01/2021 08:54:09",
      "content": "<p><a href=\"https://www.kaggle.com/lobrien\" target=\"_blank\">@lobrien</a> as far as I know … Sea-Thru requires RAW files … not jpg. </p>",
      "rawMarkdown": "lobrien as far as I know ... Sea-Thru requires RAW files ... not jpg.",
      "votes": null
    },
    {
      "id": "1601516",
      "postDate": "12/01/2021 11:22:37",
      "content": "<p>Thank you so much for responding😇. Oh I see, seems like tensorflow implementation is much more appropriate for this data, than <code>cv2.createCLAHE</code>. </p>",
      "rawMarkdown": "Thank you so much for responding😇. Oh I see, seems like tensorflow implementation is much more appropriate for this data, than `cv2.createCLAHE`.",
      "votes": null
    },
    {
      "id": "1602073",
      "postDate": "12/01/2021 18:35:34",
      "content": "<p>Yes, I don't think Sea-Thru is realistic for this challenge. It would be nice, but I don't think it's realistic.</p>",
      "rawMarkdown": "Yes, I don't think Sea-Thru is realistic for this challenge. It would be nice, but I don't think it's realistic.",
      "votes": null
    },
    {
      "id": "1604964",
      "postDate": "12/03/2021 22:16:35",
      "content": "<h2>U-shape Transformer Underwater Image Enhancement</h2>\n<p>paper: <a href=\"https://arxiv.org/abs/2111.11843\" target=\"_blank\">https://arxiv.org/abs/2111.11843</a><br>\ncode (pytorch): <a href=\"https://github.com/LintaoPeng/U-shape_Transformer\" target=\"_blank\">https://github.com/LintaoPeng/U-shape_Transformer</a></p>\n<p><img src=\"https://raw.githubusercontent.com/LintaoPeng/U-shape_Transformer/main/figs/data.png\" alt=\"\"></p>",
      "rawMarkdown": "## U-shape Transformer Underwater Image Enhancement\n\npaper: https://arxiv.org/abs/2111.11843\ncode (pytorch): https://github.com/LintaoPeng/U-shape_Transformer\n\n![](https://raw.githubusercontent.com/LintaoPeng/U-shape_Transformer/main/figs/data.png)",
      "votes": null
    },
    {
      "id": "1629781",
      "postDate": "12/26/2021 14:45:09",
      "content": "<p>I see that the <code>cv2.createCLAHE</code> makes the objects more explicit and noticeable than <code>tensorflow implementation</code>. Why is <code>tensorflow implementation</code> more appropriate for this data?</p>",
      "rawMarkdown": "I see that the `cv2.createCLAHE` makes the objects more explicit and noticeable than `tensorflow implementation`. Why is `tensorflow implementation` more appropriate for this data?",
      "votes": null
    },
    {
      "id": "1636002",
      "postDate": "01/02/2022 13:52:12",
      "content": "<p>Thank you for sharing the great method!!! all the replies are good as well.</p>",
      "rawMarkdown": "Thank you for sharing the great method!!! all the replies are good as well.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1595827,
      "author_name": "roberterffmeyer",
      "author_url": "",
      "post_date": "11/26/2021 02:56:27",
      "content": "<p>so I think this is for humans to be able to see things better. Neural networks shouldn't mind about underwater murkiness</p>",
      "votes": null,
      "replies": [
        {
          "id": 1596490,
          "author_name": "paweljankiewicz",
          "author_url": "",
          "post_date": "11/26/2021 14:44:29",
          "content": "<p>With limited data it can be helpful to normalize the images to the same color space. Under water there is also a quick visibility falloff which can make things more difficult for the neural network. In the worst case it could be used to augment the training dataset.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1597525,
          "author_name": "faisalalsrheed",
          "author_url": "",
          "post_date": "11/27/2021 15:49:37",
          "content": "<p><img src=\"https://i.postimg.cc/PqwNSnMv/Object.jpg\" alt=\"\"></p>\n<p><strong>Reference</strong>: <a href=\"https://www.hindawi.com/journals/js/2020/6707328/\" target=\"_blank\">https://www.hindawi.com/journals/js/2020/6707328/</a></p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1597688,
          "author_name": "lobrien",
          "author_url": "",
          "post_date": "11/27/2021 19:25:19",
          "content": "<p>If I read the paper correctly, they <em>start</em> with object detection and try to create areas of high salience, to which they apply channel manipulation to shift the color. If I'm correct, the techniques in this paper wouldn't be very helpful to this challenge. A general technique such as Sea-Thru (<a href=\"https://openaccess.thecvf.com/content_CVPR_2019/html/Akkaynak_Sea-Thru_A_Method_for_Removing_Water_From_Underwater_Images_CVPR_2019_paper.html\" target=\"_blank\">https://openaccess.thecvf.com/content_CVPR_2019/html/Akkaynak_Sea-Thru_A_Method_for_Removing_Water_From_Underwater_Images_CVPR_2019_paper.html</a>) would be very beneficial but:</p>\n<ul>\n<li>Sea-Thru requires a depth map; </li>\n<li>Sea-Thru's parameters are not published; and </li>\n<li>I believe it's patented.  </li>\n</ul>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1597701,
          "author_name": "faisalalsrheed",
          "author_url": "",
          "post_date": "11/27/2021 19:48:17",
          "content": "<p>Thank you for sharing about sea-thru </p>\n<p>wow<br>\n<img src=\"https://i.postimg.cc/6qpZCTFK/sea-thru3.jpg\" alt=\"\"><br>\n<img src=\"https://i.postimg.cc/MZ9Vqbjp/sea-thru1.jpg\" alt=\"\"><br>\n<img src=\"https://i.postimg.cc/FzCLpNQL/sea-thru2.jpg\" alt=\"\"></p>\n<p><strong>Reference:</strong> <a href=\"https://www.deryaakkaynak.com/sea-thru\" target=\"_blank\">https://www.deryaakkaynak.com/sea-thru</a></p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1599421,
          "author_name": "remekkinas",
          "author_url": "",
          "post_date": "11/29/2021 12:27:17",
          "content": "<p>Sea-thru looks great but … it is not available so far. Second … it would be great to build model which is not only accurate but fast as well (second competition requirement). Putting sea-thru in data pipeline would slow down inference a lot in my opinion. </p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1599440,
          "author_name": "paweljankiewicz",
          "author_url": "",
          "post_date": "11/29/2021 12:46:58",
          "content": "<p>9 hours for the inference is plenty time to do things like applying not one but several models. Remember that you can use pretrained models. Some of the notebooks take 20 seconds to predict all test data during inference.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1599443,
          "author_name": "remekkinas",
          "author_url": "",
          "post_date": "11/29/2021 12:50:38",
          "content": "<p>I am talking about this:</p>\n<blockquote>\n  <p>The TensorFlow team has been working closely with CSIRO and plans to use the winning solutions to create an on-device model for real-time detection of COTS. Additional prizes will be given to the fastest model using Tensorflow. </p>\n  <p>Achieve a private leaderboard score better than or equal to the private leaderboard score of the Top 10% of teams on the private leaderboard. For example, if there are 1000 teams, any selected submission with a score greater than the 100th place team's private score will be eligible.<br>\n      Use TensorFlow 2.X on GPU</p>\n</blockquote>\n<p>So if you want to be fast you shoud be as lightweight as possible …</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1599540,
          "author_name": "paweljankiewicz",
          "author_url": "",
          "post_date": "11/29/2021 14:15:03",
          "content": "<p>Makes sense. Thank you for the clarification.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1599544,
          "author_name": "remekkinas",
          "author_url": "",
          "post_date": "11/29/2021 14:19:54",
          "content": "<p>No problem. Just this was my first move - to enhance photo quality … and then … realized (after reading competition rules) that coud be good direction but time consuming :) … </p>\n<p>P.S.<br>\nMiło widzieć :) Pozdrowienia!</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1601406,
          "author_name": "remekkinas",
          "author_url": "",
          "post_date": "12/01/2021 08:54:09",
          "content": "<p><a href=\"https://www.kaggle.com/lobrien\" target=\"_blank\">@lobrien</a> as far as I know … Sea-Thru requires RAW files … not jpg. </p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1602073,
          "author_name": "lobrien",
          "author_url": "",
          "post_date": "12/01/2021 18:35:34",
          "content": "<p>Yes, I don't think Sea-Thru is realistic for this challenge. It would be nice, but I don't think it's realistic.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1596078,
      "author_name": "shakshyathedetector",
      "author_url": "",
      "post_date": "11/26/2021 07:20:53",
      "content": "<p>How can it help in this problem ??</p>",
      "votes": null,
      "replies": [
        {
          "id": 1597517,
          "author_name": "faisalalsrheed",
          "author_url": "",
          "post_date": "11/27/2021 15:29:49",
          "content": "<p>Just like any other neural network project, There is only one way to know……..to try it :)</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1597488,
      "author_name": "soumya9977",
      "author_url": "",
      "post_date": "11/27/2021 14:54:28",
      "content": "<p>Nice topic <a href=\"https://www.kaggle.com/faisalalsrheed\" target=\"_blank\">@faisalalsrheed</a>, I was also thinking about reducing the blurry ness from the images and enhancing a bit, I tried with <code>CLAHE</code> and it is giving this result. I dont know this is good enough or not. Maybe further improvement can yield better results.  <em><code>From the image, it seems like all the rocks, plants, and other underwater objects are on the ground and sunlight falling upon them, not inside a sea.</code></em></p>\n<p>\n<img src=\"https://i.imgur.com/ZvlbMoH.png\">\n</p>\n<ul>\n<li>this is a sample result from Histogram Equalizer,</li>\n</ul>\n<p>\n<img src=\"https://i.imgur.com/SYwHWhQ.png\">\n</p>\n<p><code>source:</code>  <a href=\"https://www.kaggle.com/c/tensorflow-great-barrier-reef/discussion/291063\" target=\"_blank\">8 Methods on Underwater Image Enhancement and Color Restoration, With Code</a></p>",
      "votes": null,
      "replies": [
        {
          "id": 1597508,
          "author_name": "faisalalsrheed",
          "author_url": "",
          "post_date": "11/27/2021 15:18:34",
          "content": "<p><code>CLAHE</code> is well known for Image enhancement on digital x-ray images.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1597514,
          "author_name": "soumya9977",
          "author_url": "",
          "post_date": "11/27/2021 15:24:56",
          "content": "<p>I did not know that before. Just got to know about this while browsing through some github repos,</p>\n<ul>\n<li><a href=\"https://github.com/asalmada/x-ray-images-enhancement\" target=\"_blank\">x ray images enhancement</a></li>\n</ul>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1597549,
      "author_name": "lukaszborecki",
      "author_url": "",
      "post_date": "11/27/2021 16:18:57",
      "content": "<p>This is wow :) Augmentation is the key </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1599835,
      "author_name": "ipythonx",
      "author_url": "",
      "post_date": "11/29/2021 21:51:28",
      "content": "<p>For CLAHE, If you're using tensorflow, you can try </p>\n<pre><code>\n\n ():\n     ():\n        \n        im = tf.cast(im[..., c], tf.int32)\n        \n        histo = tf.histogram_fixed_width(im, [, ], nbins=)\n\n        \n        nonzero = tf.where(tf.not_equal(histo, ))\n        nonzero_histo = tf.reshape(tf.gather(histo, nonzero), [-])\n        step = (tf.reduce_sum(nonzero_histo) - nonzero_histo[-]) // \n\n         ():\n            \n            \n            lut = (tf.cumsum(histo) + (step // )) // step\n            \n            lut = tf.concat([[], lut[:-]], )\n            \n            \n             tf.clip_by_value(lut, , )\n\n        \n        \n        result = tf.cond(\n            tf.equal(step, ), : im,\n            : tf.gather(build_lut(histo, step), im))\n         tf.cast(result, tf.uint8)\n\n     mode == :\n        image = scale_channel(image, )\n         tf.cast(image, tf.float32)\n     mode == :\n        s1 = scale_channel(image, )\n        s2 = scale_channel(image, )\n        s3 = scale_channel(image, )\n        image = tf.stack([s1, s2, s3], -)\n         tf.cast(image, tf.float32)\n\n\n ():\n     IMAGE_SIZE != x.shape[]  IMAGE_SIZE != x.shape[]:\n        x_scale, y_scale = IMAGE_SIZE / x.shape[], IMAGE_SIZE / x.shape[]\n        y = y * [x_scale, y_scale, x_scale, y_scale, ]\n        x = tf.image.resize(x, [IMAGE_SIZE, IMAGE_SIZE])\n    x = equalize(x, mode=)\n    x = tf.divide(x, )\n     x, y\n</code></pre>\n<p>Sample output: </p>\n<p><img src=\"https://user-images.githubusercontent.com/17668390/143948453-96101885-42aa-4007-a9fc-9f1fa2ffb689.gif\" alt=\"Animation5\"></p>",
      "votes": null,
      "replies": [
        {
          "id": 1599839,
          "author_name": "ipythonx",
          "author_url": "",
          "post_date": "11/29/2021 21:55:44",
          "content": "<p>Here are a few more results of it</p>\n<p><img src=\"https://user-images.githubusercontent.com/17668390/143948790-1a7a21f9-ef4c-4a86-a8ee-d44221255877.png\"> <img src=\"https://user-images.githubusercontent.com/17668390/143948795-d494307d-3fab-4eaa-a5ee-7db7950ce7ee.png\"> <img src=\"https://user-images.githubusercontent.com/17668390/143948804-30d7fcac-b695-4832-9fac-b9327e6f349a.png\"></p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1601031,
          "author_name": "soumya9977",
          "author_url": "",
          "post_date": "12/01/2021 00:57:52",
          "content": "<p>Hi <a href=\"https://www.kaggle.com/ipythonx\" target=\"_blank\">@ipythonx</a>, I was trying your code, but the output image is not coming as yours, this is what I did,</p>\n<pre><code># reading an image using plt\nimg_plt = plt.imread('../input/tensorflow-great-barrier-reef/train_images/video_1/9101.jpg')\n\n# your function definition here\ndef equalize(image, mode='grayscale'):\n    ...\n    ...\n\n# calling your function\nx = equalize(img_plt, mode='rgb')\n# plotting that image,x\nplt.imshow(x.numpy())\n</code></pre>\n<p>This is the Output:</p>\n<p>\n<img src=\"https://i.imgur.com/cuZ6KPO.png\">\n</p>\n<p><code>Can you please help, mention any point that im missing. Thank you.</code> Is this because of using matplotlib for reading the image, I tried with cv2 for reading the image too, but the results were same.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1601164,
          "author_name": "ipythonx",
          "author_url": "",
          "post_date": "12/01/2021 04:34:31",
          "content": "<p>try </p>\n<pre><code>plt.imshow(x.numpy() / 255.)\n\nor \n\nplt.imshow(x.numpy().astype(np.uint8)\n</code></pre>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1601221,
          "author_name": "soumya9977",
          "author_url": "",
          "post_date": "12/01/2021 05:17:21",
          "content": "<p>Thank you <a href=\"https://www.kaggle.com/ipythonx\" target=\"_blank\">@ipythonx</a> normalizing with 255. worked. I have read your code but I really don't understand the logic behind the code. can you please give some insights? I understand that you implemented <code>CLAHE</code>, but why not use any build-in like cv2 and stuff for <code>CLAHE</code>, how your <code>equalize</code> function is different from the build-in <code>CLAHE</code> function. cause build-in <code>CLAHE</code> looks like this,</p>\n<p>\n<img src=\"https://i.imgur.com/ZvlbMoH.png\">\n</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1601386,
          "author_name": "ipythonx",
          "author_url": "",
          "post_date": "12/01/2021 08:28:52",
          "content": "<p>The above equalize implementation is taken from <a href=\"https://github.com/tensorflow/models/blob/master/official/vision/image_classification/augment.py#L480\" target=\"_blank\">tensorflow/model</a>, which I think similar to <a href=\"https://www.tensorflow.org/addons/api_docs/python/tfa/image/equalize\" target=\"_blank\">tfa.image.equalize</a>; <a href=\"https://github.com/tensorflow/addons/pull/2362\" target=\"_blank\">discussion</a>. </p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1601516,
          "author_name": "soumya9977",
          "author_url": "",
          "post_date": "12/01/2021 11:22:37",
          "content": "<p>Thank you so much for responding😇. Oh I see, seems like tensorflow implementation is much more appropriate for this data, than <code>cv2.createCLAHE</code>. </p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1629781,
          "author_name": "aengusng",
          "author_url": "",
          "post_date": "12/26/2021 14:45:09",
          "content": "<p>I see that the <code>cv2.createCLAHE</code> makes the objects more explicit and noticeable than <code>tensorflow implementation</code>. Why is <code>tensorflow implementation</code> more appropriate for this data?</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1604964,
      "author_name": "ipythonx",
      "author_url": "",
      "post_date": "12/03/2021 22:16:35",
      "content": "<h2>U-shape Transformer Underwater Image Enhancement</h2>\n<p>paper: <a href=\"https://arxiv.org/abs/2111.11843\" target=\"_blank\">https://arxiv.org/abs/2111.11843</a><br>\ncode (pytorch): <a href=\"https://github.com/LintaoPeng/U-shape_Transformer\" target=\"_blank\">https://github.com/LintaoPeng/U-shape_Transformer</a></p>\n<p><img src=\"https://raw.githubusercontent.com/LintaoPeng/U-shape_Transformer/main/figs/data.png\" alt=\"\"></p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1636002,
      "author_name": "eugeneryu",
      "author_url": "",
      "post_date": "01/02/2022 13:52:12",
      "content": "<p>Thank you for sharing the great method!!! all the replies are good as well.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1595024": "Fast underwater image enhancement for Improved Visual Perception. #TensorFlow #PyTorch\n\n\n![](https://i.postimg.cc/RCL27DtC/underwater.jpg)\n\n\n![](https://i.postimg.cc/wv8xKmfq/funie.jpg)\n\n\n![](https://i.postimg.cc/02J22v3X/Qualitative-performance-comparison.jpg)\n\n\n\n\n\nPaper: https://ieeexplore.ieee.org/document/9001231\nPreprint: https://arxiv.org/pdf/1903.09766.pdf\nDatasets: http://irvlab.cs.umn.edu/resources/euvp-dataset\nGithub: https://github.com/xahidbuffon/FUnIE-GAN",
    "1595827": "so I think this is for humans to be able to see things better. Neural networks shouldn't mind about underwater murkiness",
    "1596078": "How can it help in this problem ??",
    "1596490": "With limited data it can be helpful to normalize the images to the same color space. Under water there is also a quick visibility falloff which can make things more difficult for the neural network. In the worst case it could be used to augment the training dataset.",
    "1597488": "Nice topic @faisalalsrheed, I was also thinking about reducing the blurry ness from the images and enhancing a bit, I tried with `CLAHE` and it is giving this result. I dont know this is good enough or not. Maybe further improvement can yield better results.  *`From the image, it seems like all the rocks, plants, and other underwater objects are on the ground and sunlight falling upon them, not inside a sea.`*\n\n<p align=\"center\">\n<img width=\"900\" src=\"https://i.imgur.com/ZvlbMoH.png\">\n</p>\n\n- this is a sample result from Histogram Equalizer,\n\n<p align=\"center\">\n<img width=\"900\" src=\"https://i.imgur.com/SYwHWhQ.png\">\n</p>\n`source:`  [8 Methods on Underwater Image Enhancement and Color Restoration, With Code](https://www.kaggle.com/c/tensorflow-great-barrier-reef/discussion/291063)",
    "1597508": "`CLAHE ` is well known for Image enhancement on digital x-ray images.",
    "1597514": "I did not know that before. Just got to know about this while browsing through some github repos,\n- [x ray images enhancement](https://github.com/asalmada/x-ray-images-enhancement)",
    "1597517": "Just like any other neural network project, There is only one way to know........to try it :)",
    "1597525": "![](https://i.postimg.cc/PqwNSnMv/Object.jpg)\n\n**Reference**: https://www.hindawi.com/journals/js/2020/6707328/",
    "1597549": "This is wow :) Augmentation is the key",
    "1597688": "If I read the paper correctly, they _start_ with object detection and try to create areas of high salience, to which they apply channel manipulation to shift the color. If I'm correct, the techniques in this paper wouldn't be very helpful to this challenge. A general technique such as Sea-Thru (https://openaccess.thecvf.com/content_CVPR_2019/html/Akkaynak_Sea-Thru_A_Method_for_Removing_Water_From_Underwater_Images_CVPR_2019_paper.html) would be very beneficial but:\n\n* Sea-Thru requires a depth map; \n* Sea-Thru's parameters are not published; and \n* I believe it's patented.",
    "1597701": "Thank you for sharing about sea-thru \n\nwow\n![](https://i.postimg.cc/6qpZCTFK/sea-thru3.jpg)\n![](https://i.postimg.cc/MZ9Vqbjp/sea-thru1.jpg)\n![](https://i.postimg.cc/FzCLpNQL/sea-thru2.jpg)\n\n\n**Reference:** https://www.deryaakkaynak.com/sea-thru",
    "1599421": "Sea-thru looks great but ... it is not available so far. Second ... it would be great to build model which is not only accurate but fast as well (second competition requirement). Putting sea-thru in data pipeline would slow down inference a lot in my opinion.",
    "1599440": "9 hours for the inference is plenty time to do things like applying not one but several models. Remember that you can use pretrained models. Some of the notebooks take 20 seconds to predict all test data during inference.",
    "1599443": "I am talking about this:\n> The TensorFlow team has been working closely with CSIRO and plans to use the winning solutions to create an on-device model for real-time detection of COTS. Additional prizes will be given to the fastest model using Tensorflow. \n\n> Achieve a private leaderboard score better than or equal to the private leaderboard score of the Top 10% of teams on the private leaderboard. For example, if there are 1000 teams, any selected submission with a score greater than the 100th place team's private score will be eligible.\n    Use TensorFlow 2.X on GPU\n\nSo if you want to be fast you shoud be as lightweight as possible ...",
    "1599540": "Makes sense. Thank you for the clarification.",
    "1599544": "No problem. Just this was my first move - to enhance photo quality ... and then ... realized (after reading competition rules) that coud be good direction but time consuming :) ... \n\nP.S.\nMiło widzieć :) Pozdrowienia!",
    "1599835": "For CLAHE, If you're using tensorflow, you can try \n\n```\n# https://github.com/tensorflow/models\n@tf.function\ndef equalize(image, mode='grayscale'):\n    def scale_channel(im, c):\n        \"\"\"Scale the data in the channel to implement equalize.\"\"\"\n        im = tf.cast(im[..., c], tf.int32)\n        # Compute the histogram of the image channel.\n        histo = tf.histogram_fixed_width(im, [0, 255], nbins=256)\n\n        # For the purposes of computing the step, filter out the nonzeros.\n        nonzero = tf.where(tf.not_equal(histo, 0))\n        nonzero_histo = tf.reshape(tf.gather(histo, nonzero), [-1])\n        step = (tf.reduce_sum(nonzero_histo) - nonzero_histo[-1]) // 255\n\n        def build_lut(histo, step):\n            # Compute the cumulative sum, shifting by step // 2\n            # and then normalization by step.\n            lut = (tf.cumsum(histo) + (step // 2)) // step\n            # Shift lut, prepending with 0.\n            lut = tf.concat([[0], lut[:-1]], 0)\n            # Clip the counts to be in range.  This is done\n            # in the C code for image.point.\n            return tf.clip_by_value(lut, 0, 255)\n\n        # If step is zero, return the original image.  Otherwise, build\n        # lut from the full histogram and step and then index from it.\n        result = tf.cond(\n            tf.equal(step, 0), lambda: im,\n            lambda: tf.gather(build_lut(histo, step), im))\n        return tf.cast(result, tf.uint8)\n\n    if mode == 'grayscale':\n        image = scale_channel(image, 0)\n        return tf.cast(image, tf.float32)\n    elif mode == 'rgb':\n        s1 = scale_channel(image, 0)\n        s2 = scale_channel(image, 1)\n        s3 = scale_channel(image, 2)\n        image = tf.stack([s1, s2, s3], -1)\n        return tf.cast(image, tf.float32)\n\n@tf.function\ndef rescale_input(x, y):\n    if IMAGE_SIZE != x.shape[2] or IMAGE_SIZE != x.shape[1]:\n        x_scale, y_scale = IMAGE_SIZE / x.shape[2], IMAGE_SIZE / x.shape[1]\n        y = y * [x_scale, y_scale, x_scale, y_scale, 1]\n        x = tf.image.resize(x, [IMAGE_SIZE, IMAGE_SIZE])\n    x = equalize(x, mode='rgb')\n    x = tf.divide(x, 255.)\n    return x, y\n```\n\nSample output: \n\n![Animation5](https://user-images.githubusercontent.com/17668390/143948453-96101885-42aa-4007-a9fc-9f1fa2ffb689.gif)",
    "1599839": "Here are a few more results of it\n\n<img src=\"https://user-images.githubusercontent.com/17668390/143948790-1a7a21f9-ef4c-4a86-a8ee-d44221255877.png\" width=\"200\" height=\"200\" /> <img src=\"https://user-images.githubusercontent.com/17668390/143948795-d494307d-3fab-4eaa-a5ee-7db7950ce7ee.png\" width=\"200\" height=\"200\" /> <img src=\"https://user-images.githubusercontent.com/17668390/143948804-30d7fcac-b695-4832-9fac-b9327e6f349a.png\" width=\"200\" height=\"200\" />",
    "1601031": "Hi @ipythonx, I was trying your code, but the output image is not coming as yours, this is what I did,\n```python\n# reading an image using plt\nimg_plt = plt.imread('../input/tensorflow-great-barrier-reef/train_images/video_1/9101.jpg')\n\n# your function definition here\ndef equalize(image, mode='grayscale'):\n    ...\n    ...\n\n# calling your function\nx = equalize(img_plt, mode='rgb')\n# plotting that image,x\nplt.imshow(x.numpy())\n```\n\nThis is the Output:\n<p align=\"center\">\n<img width=\"500\" src=\"https://i.imgur.com/cuZ6KPO.png\">\n</p>\n\n`Can you please help, mention any point that im missing. Thank you.` Is this because of using matplotlib for reading the image, I tried with cv2 for reading the image too, but the results were same.",
    "1601164": "try \n\n```\nplt.imshow(x.numpy() / 255.)\n\nor \n\nplt.imshow(x.numpy().astype(np.uint8)\n```",
    "1601221": "Thank you @ipythonx normalizing with 255. worked. I have read your code but I really don't understand the logic behind the code. can you please give some insights? I understand that you implemented `CLAHE`, but why not use any build-in like cv2 and stuff for `CLAHE`, how your `equalize` function is different from the build-in `CLAHE` function. cause build-in `CLAHE` looks like this,\n\n<p align=\"center\">\n<img width=\"900\" src=\"https://i.imgur.com/ZvlbMoH.png\">\n</p>",
    "1601386": "The above equalize implementation is taken from [tensorflow/model](https://github.com/tensorflow/models/blob/master/official/vision/image_classification/augment.py#L480), which I think similar to [tfa.image.equalize](https://www.tensorflow.org/addons/api_docs/python/tfa/image/equalize); [discussion](https://github.com/tensorflow/addons/pull/2362).",
    "1601406": "lobrien as far as I know ... Sea-Thru requires RAW files ... not jpg.",
    "1601516": "Thank you so much for responding😇. Oh I see, seems like tensorflow implementation is much more appropriate for this data, than `cv2.createCLAHE`.",
    "1602073": "Yes, I don't think Sea-Thru is realistic for this challenge. It would be nice, but I don't think it's realistic.",
    "1604964": "## U-shape Transformer Underwater Image Enhancement\n\npaper: https://arxiv.org/abs/2111.11843\ncode (pytorch): https://github.com/LintaoPeng/U-shape_Transformer\n\n![](https://raw.githubusercontent.com/LintaoPeng/U-shape_Transformer/main/figs/data.png)",
    "1629781": "I see that the `cv2.createCLAHE` makes the objects more explicit and noticeable than `tensorflow implementation`. Why is `tensorflow implementation` more appropriate for this data?",
    "1636002": "Thank you for sharing the great method!!! all the replies are good as well."
  },
  "source": "meta"
}