{
  "id": 46867,
  "title": "Is it right to gamma correction like this?",
  "url": "/competitions/sp-society-camera-model-identification/discussion/46867",
  "author_name": "",
  "post_date": "2018-01-04T10:17:05.481700500Z",
  "votes": null,
  "comment_count": 3,
  "views": 0,
  "content": "<p>The image can be altered as shown in data page description</p>\n\n<ul>\n<li>gamma correction using gamma = 0.8 </li>\n<li>gamma correction using gamma = 1.2</li>\n</ul>\n\n<p>I used the gamma correction as follows.</p>\n\n<pre><code>lut_08 = []\nlut_12 = []\ninvert_gamma = 1.0/0.8\nlut_08 = [pow(x/255., invert_gamma) * 255 for x in range(256)]\nlut_08 = lut_08*3\ninvert_gamma = 1.0/1.2\nlut_12 = [pow(x/255., invert_gamma) * 255 for x in range(256)]\nlut_12 = lut_12*3 \n\ndef do_gamma(im, gamma):\n    # Fast gamma correction with PIL's image.point() method\n    if gamma == 0.8:\n        im = im.point(lut_08)\n    elif gamma == 1.2:\n        im = im.point(lut_12)\n    else:\n        print('warning gamma value incorrect ')\n    return im\n</code></pre>",
  "messages": [
    {
      "id": "264991",
      "postDate": "01/04/2018 10:17:05",
      "content": "<p>The image can be altered as shown in data page description</p>\n\n<ul>\n<li>gamma correction using gamma = 0.8 </li>\n<li>gamma correction using gamma = 1.2</li>\n</ul>\n\n<p>I used the gamma correction as follows.</p>\n\n<pre><code>lut_08 = []\nlut_12 = []\ninvert_gamma = 1.0/0.8\nlut_08 = [pow(x/255., invert_gamma) * 255 for x in range(256)]\nlut_08 = lut_08*3\ninvert_gamma = 1.0/1.2\nlut_12 = [pow(x/255., invert_gamma) * 255 for x in range(256)]\nlut_12 = lut_12*3 \n\ndef do_gamma(im, gamma):\n    # Fast gamma correction with PIL's image.point() method\n    if gamma == 0.8:\n        im = im.point(lut_08)\n    elif gamma == 1.2:\n        im = im.point(lut_12)\n    else:\n        print('warning gamma value incorrect ')\n    return im\n</code></pre>",
      "rawMarkdown": "The image can be altered as shown in data page description\n\n - gamma correction using gamma = 0.8 \n - gamma correction using gamma = 1.2\n\nI used the gamma correction as follows.\n\n\n    lut_08 = []\n    lut_12 = []\n    invert_gamma = 1.0/0.8\n    lut_08 = [pow(x/255., invert_gamma) * 255 for x in range(256)]\n    lut_08 = lut_08*3\n    invert_gamma = 1.0/1.2\n    lut_12 = [pow(x/255., invert_gamma) * 255 for x in range(256)]\n    lut_12 = lut_12*3 \n\n    def do_gamma(im, gamma):\n        # Fast gamma correction with PIL's image.point() method\n        if gamma == 0.8:\n            im = im.point(lut_08)\n        elif gamma == 1.2:\n            im = im.point(lut_12)\n        else:\n            print('warning gamma value incorrect ')\n        return im",
      "votes": null
    },
    {
      "id": "264995",
      "postDate": "01/04/2018 10:26:29",
      "content": "<p>I think 255.*((image_ndarray/255.)**(1./gamma)) should work, casted to uint8</p>",
      "rawMarkdown": "I think 255.*((image_ndarray/255.)**(1./gamma)) should work, casted to uint8",
      "votes": null
    },
    {
      "id": "265089",
      "postDate": "01/04/2018 15:49:23",
      "content": "<p>use ski-learn , exposure.adjust_gamma()</p>",
      "rawMarkdown": "use ski-learn , exposure.adjust_gamma()",
      "votes": null
    },
    {
      "id": "265678",
      "postDate": "01/06/2018 09:19:19",
      "content": "<p>thanks~.</p>",
      "rawMarkdown": "thanks~.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 264995,
      "author_name": "datasec",
      "author_url": "",
      "post_date": "01/04/2018 10:26:29",
      "content": "<p>I think 255.*((image_ndarray/255.)**(1./gamma)) should work, casted to uint8</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 265089,
      "author_name": "sumitjha19",
      "author_url": "",
      "post_date": "01/04/2018 15:49:23",
      "content": "<p>use ski-learn , exposure.adjust_gamma()</p>",
      "votes": null,
      "replies": [
        {
          "id": 265678,
          "author_name": "ttagu99",
          "author_url": "",
          "post_date": "01/06/2018 09:19:19",
          "content": "<p>thanks~.</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "264991": "The image can be altered as shown in data page description\n\n - gamma correction using gamma = 0.8 \n - gamma correction using gamma = 1.2\n\nI used the gamma correction as follows.\n\n\n    lut_08 = []\n    lut_12 = []\n    invert_gamma = 1.0/0.8\n    lut_08 = [pow(x/255., invert_gamma) * 255 for x in range(256)]\n    lut_08 = lut_08*3\n    invert_gamma = 1.0/1.2\n    lut_12 = [pow(x/255., invert_gamma) * 255 for x in range(256)]\n    lut_12 = lut_12*3 \n\n    def do_gamma(im, gamma):\n        # Fast gamma correction with PIL's image.point() method\n        if gamma == 0.8:\n            im = im.point(lut_08)\n        elif gamma == 1.2:\n            im = im.point(lut_12)\n        else:\n            print('warning gamma value incorrect ')\n        return im",
    "264995": "I think 255.*((image_ndarray/255.)**(1./gamma)) should work, casted to uint8",
    "265089": "use ski-learn , exposure.adjust_gamma()",
    "265678": "thanks~."
  },
  "source": "meta"
}