{
  "id": 351806,
  "title": "Solve sloth with abs()",
  "url": "/competitions/ai-village-ctf/discussion/351806",
  "author_name": "",
  "post_date": "2022-09-12T00:22:41.149743300Z",
  "votes": 30,
  "comment_count": 13,
  "views": 0,
  "content": "<p>The trick I used to solve sloth was to take the absolute value of the (complex) fft:</p>\n<pre><code>import numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy import fftpack\n\nim = plt.imread(f\"./secret.sloth/secret-sloth.png\").astype(float)\nim_fft = fftpack.fft2(im)\nplt.imshow(np.abs(im_fft))\n</code></pre>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F40584%2Fe496f42e6430b158e9cde4f197ad8ca5%2Ffft.png?generation=1662942121479542&amp;alt=media\" alt=\"\"></p>",
  "messages": [
    {
      "id": "1935213",
      "postDate": "09/12/2022 00:22:41",
      "content": "<p>The trick I used to solve sloth was to take the absolute value of the (complex) fft:</p>\n<pre><code>import numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy import fftpack\n\nim = plt.imread(f\"./secret.sloth/secret-sloth.png\").astype(float)\nim_fft = fftpack.fft2(im)\nplt.imshow(np.abs(im_fft))\n</code></pre>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F40584%2Fe496f42e6430b158e9cde4f197ad8ca5%2Ffft.png?generation=1662942121479542&amp;alt=media\" alt=\"\"></p>",
      "rawMarkdown": "The trick I used to solve sloth was to take the absolute value of the (complex) fft:\n\n```\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy import fftpack\n\nim = plt.imread(f\"./secret.sloth/secret-sloth.png\").astype(float)\nim_fft = fftpack.fft2(im)\nplt.imshow(np.abs(im_fft))\n```\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F40584%2Fe496f42e6430b158e9cde4f197ad8ca5%2Ffft.png?generation=1662942121479542&alt=media)",
      "votes": null
    },
    {
      "id": "1935214",
      "postDate": "09/12/2022 00:23:16",
      "content": "<p>That's awesome. Great solution!</p>",
      "rawMarkdown": "That's awesome. Great solution!",
      "votes": null
    },
    {
      "id": "1935219",
      "postDate": "09/12/2022 00:27:47",
      "content": "<p>The real part of the FFT is also enough! I found this way later than I would like to admit (after trying various steganography SOTAs).</p>\n<pre><code>import cv2\nimport scipy\nimport numpy as np\nimport scipy.fftpack\nfrom PIL import Image\n\nimg = Image.open('../input/ai-village-ctf/secret.sloth/secret-sloth.png').convert('RGB')\nimg = np.array(img)\n\nfft = scipy.fftpack.fft2(img)\nplt.imshow(fft.real);\n</code></pre>",
      "rawMarkdown": "The real part of the FFT is also enough! I found this way later than I would like to admit (after trying various steganography SOTAs).\n\n```\nimport cv2\nimport scipy\nimport numpy as np\nimport scipy.fftpack\nfrom PIL import Image\n\nimg = Image.open('../input/ai-village-ctf/secret.sloth/secret-sloth.png').convert('RGB')\nimg = np.array(img)\n\nfft = scipy.fftpack.fft2(img)\nplt.imshow(fft.real);\n```",
      "votes": null
    },
    {
      "id": "1935224",
      "postDate": "09/12/2022 00:30:32",
      "content": "<p>I'm a beginner at FFT, but why doing <code>fft2(im)</code> instead of <code>fft2(im, axes=(0,1))</code> ?<br>\nCould someone please give me a direction?</p>",
      "rawMarkdown": "I'm a beginner at FFT, but why doing `fft2(im)` instead of `fft2(im, axes=(0,1))` ?\nCould someone please give me a direction?",
      "votes": null
    },
    {
      "id": "1936423",
      "postDate": "09/12/2022 18:32:59",
      "content": "<p>Awesome <a href=\"https://www.kaggle.com/chris62\" target=\"_blank\">@chris62</a> and congrats for 4th place!</p>",
      "rawMarkdown": "Awesome @chris62 and congrats for 4th place!",
      "votes": null
    },
    {
      "id": "1937901",
      "postDate": "09/13/2022 18:22:59",
      "content": "<p>Thanks! I loved your notebook as well - It was neat seeing how you approached each problem!</p>",
      "rawMarkdown": "Thanks! I loved your notebook as well - It was neat seeing how you approached each problem!",
      "votes": null
    },
    {
      "id": "1937903",
      "postDate": "09/13/2022 18:23:46",
      "content": "<p>Ah, nice! That's probably the more \"correct\" solution 😄 but I suppose whatever gets the flag is good!</p>",
      "rawMarkdown": "Ah, nice! That's probably the more \"correct\" solution 😄 but I suppose whatever gets the flag is good!",
      "votes": null
    },
    {
      "id": "1937906",
      "postDate": "09/13/2022 18:24:39",
      "content": "<p>Hm, I'm not sure - I did it because it worked and then I didn't try anything else 😂 - it may be that axes=(0,1) is more important for other signal processing, etc.</p>",
      "rawMarkdown": "Hm, I'm not sure - I did it because it worked and then I didn't try anything else 😂 - it may be that axes=(0,1) is more important for other signal processing, etc.",
      "votes": null
    },
    {
      "id": "1937908",
      "postDate": "09/13/2022 18:25:38",
      "content": "<p>Thanks! It was both an intensely frustrating but rewarding challenge 😄 </p>",
      "rawMarkdown": "Thanks! It was both an intensely frustrating but rewarding challenge 😄",
      "votes": null
    },
    {
      "id": "1938379",
      "postDate": "09/14/2022 05:55:04",
      "content": "<p>As a rookie, just like how I didn't know what to do with the Sloth image, I am not sure what I am looking at in this solution and the image 😃<br>\nis the flag value \"SPECTRAL\"? it is barely visible 🤕</p>",
      "rawMarkdown": "As a rookie, just like how I didn't know what to do with the Sloth image, I am not sure what I am looking at in this solution and the image 😃\nis the flag value \"SPECTRAL\"? it is barely visible 🤕",
      "votes": null
    },
    {
      "id": "1938381",
      "postDate": "09/14/2022 05:56:52",
      "content": "<p>What are the topics that one need to know to have arrived at this solution? Any resources to understand this?</p>",
      "rawMarkdown": "What are the topics that one need to know to have arrived at this solution? Any resources to understand this?",
      "votes": null
    },
    {
      "id": "1938394",
      "postDate": "09/14/2022 06:06:41",
      "content": "<p>Yes. If you read this paper about stenography <a href=\"https://docsdrive.com/pdfs/ansinet/jas/2010/2094-2100.pdf\" target=\"_blank\">here</a>, you will see there are two approaches to hiding text in images. One approach is to hide text in the original image (whether that be the actual image via LSB or the raw text file). The second method is the most common for companies when they watermark their images. In the second method, you convert the image with <code>fft2</code> first and then add the text to the transformed spectral image. Then convert the image back to the original space.</p>",
      "rawMarkdown": "Yes. If you read this paper about stenography [here][1], you will see there are two approaches to hiding text in images. One approach is to hide text in the original image (whether that be the actual image via LSB or the raw text file). The second method is the most common for companies when they watermark their images. In the second method, you convert the image with `fft2` first and then add the text to the transformed spectral image. Then convert the image back to the original space.\n\n[1]: https://docsdrive.com/pdfs/ansinet/jas/2010/2094-2100.pdf",
      "votes": null
    },
    {
      "id": "1938428",
      "postDate": "09/14/2022 06:29:27",
      "content": "<p>Thanks, I will take a look at the paper.</p>",
      "rawMarkdown": "Thanks, I will take a look at the paper.",
      "votes": null
    },
    {
      "id": "1939260",
      "postDate": "09/14/2022 15:50:50",
      "content": "<p>congrats <a href=\"https://www.kaggle.com/chris62\" target=\"_blank\">@chris62</a> for your amazing work. keep helping us to learn.</p>",
      "rawMarkdown": "congrats @chris62 for your amazing work. keep helping us to learn.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1935214,
      "author_name": "cdeotte",
      "author_url": "",
      "post_date": "09/12/2022 00:23:16",
      "content": "<p>That's awesome. Great solution!</p>",
      "votes": null,
      "replies": [
        {
          "id": 1937901,
          "author_name": "chris62",
          "author_url": "",
          "post_date": "09/13/2022 18:22:59",
          "content": "<p>Thanks! I loved your notebook as well - It was neat seeing how you approached each problem!</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1935219,
      "author_name": "vkonstantakos",
      "author_url": "",
      "post_date": "09/12/2022 00:27:47",
      "content": "<p>The real part of the FFT is also enough! I found this way later than I would like to admit (after trying various steganography SOTAs).</p>\n<pre><code>import cv2\nimport scipy\nimport numpy as np\nimport scipy.fftpack\nfrom PIL import Image\n\nimg = Image.open('../input/ai-village-ctf/secret.sloth/secret-sloth.png').convert('RGB')\nimg = np.array(img)\n\nfft = scipy.fftpack.fft2(img)\nplt.imshow(fft.real);\n</code></pre>",
      "votes": null,
      "replies": [
        {
          "id": 1937903,
          "author_name": "chris62",
          "author_url": "",
          "post_date": "09/13/2022 18:23:46",
          "content": "<p>Ah, nice! That's probably the more \"correct\" solution 😄 but I suppose whatever gets the flag is good!</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1935224,
      "author_name": "thariqnugrohotomo",
      "author_url": "",
      "post_date": "09/12/2022 00:30:32",
      "content": "<p>I'm a beginner at FFT, but why doing <code>fft2(im)</code> instead of <code>fft2(im, axes=(0,1))</code> ?<br>\nCould someone please give me a direction?</p>",
      "votes": null,
      "replies": [
        {
          "id": 1937906,
          "author_name": "chris62",
          "author_url": "",
          "post_date": "09/13/2022 18:24:39",
          "content": "<p>Hm, I'm not sure - I did it because it worked and then I didn't try anything else 😂 - it may be that axes=(0,1) is more important for other signal processing, etc.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1936423,
      "author_name": "wrrosa",
      "author_url": "",
      "post_date": "09/12/2022 18:32:59",
      "content": "<p>Awesome <a href=\"https://www.kaggle.com/chris62\" target=\"_blank\">@chris62</a> and congrats for 4th place!</p>",
      "votes": null,
      "replies": [
        {
          "id": 1937908,
          "author_name": "chris62",
          "author_url": "",
          "post_date": "09/13/2022 18:25:38",
          "content": "<p>Thanks! It was both an intensely frustrating but rewarding challenge 😄 </p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1938379,
      "author_name": "vangap",
      "author_url": "",
      "post_date": "09/14/2022 05:55:04",
      "content": "<p>As a rookie, just like how I didn't know what to do with the Sloth image, I am not sure what I am looking at in this solution and the image 😃<br>\nis the flag value \"SPECTRAL\"? it is barely visible 🤕</p>",
      "votes": null,
      "replies": [
        {
          "id": 1938381,
          "author_name": "vangap",
          "author_url": "",
          "post_date": "09/14/2022 05:56:52",
          "content": "<p>What are the topics that one need to know to have arrived at this solution? Any resources to understand this?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1938394,
          "author_name": "cdeotte",
          "author_url": "",
          "post_date": "09/14/2022 06:06:41",
          "content": "<p>Yes. If you read this paper about stenography <a href=\"https://docsdrive.com/pdfs/ansinet/jas/2010/2094-2100.pdf\" target=\"_blank\">here</a>, you will see there are two approaches to hiding text in images. One approach is to hide text in the original image (whether that be the actual image via LSB or the raw text file). The second method is the most common for companies when they watermark their images. In the second method, you convert the image with <code>fft2</code> first and then add the text to the transformed spectral image. Then convert the image back to the original space.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1938428,
          "author_name": "vangap",
          "author_url": "",
          "post_date": "09/14/2022 06:29:27",
          "content": "<p>Thanks, I will take a look at the paper.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1939260,
      "author_name": "rahul029",
      "author_url": "",
      "post_date": "09/14/2022 15:50:50",
      "content": "<p>congrats <a href=\"https://www.kaggle.com/chris62\" target=\"_blank\">@chris62</a> for your amazing work. keep helping us to learn.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1935213": "The trick I used to solve sloth was to take the absolute value of the (complex) fft:\n\n```\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy import fftpack\n\nim = plt.imread(f\"./secret.sloth/secret-sloth.png\").astype(float)\nim_fft = fftpack.fft2(im)\nplt.imshow(np.abs(im_fft))\n```\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F40584%2Fe496f42e6430b158e9cde4f197ad8ca5%2Ffft.png?generation=1662942121479542&alt=media)",
    "1935214": "That's awesome. Great solution!",
    "1935219": "The real part of the FFT is also enough! I found this way later than I would like to admit (after trying various steganography SOTAs).\n\n```\nimport cv2\nimport scipy\nimport numpy as np\nimport scipy.fftpack\nfrom PIL import Image\n\nimg = Image.open('../input/ai-village-ctf/secret.sloth/secret-sloth.png').convert('RGB')\nimg = np.array(img)\n\nfft = scipy.fftpack.fft2(img)\nplt.imshow(fft.real);\n```",
    "1935224": "I'm a beginner at FFT, but why doing `fft2(im)` instead of `fft2(im, axes=(0,1))` ?\nCould someone please give me a direction?",
    "1936423": "Awesome @chris62 and congrats for 4th place!",
    "1937901": "Thanks! I loved your notebook as well - It was neat seeing how you approached each problem!",
    "1937903": "Ah, nice! That's probably the more \"correct\" solution 😄 but I suppose whatever gets the flag is good!",
    "1937906": "Hm, I'm not sure - I did it because it worked and then I didn't try anything else 😂 - it may be that axes=(0,1) is more important for other signal processing, etc.",
    "1937908": "Thanks! It was both an intensely frustrating but rewarding challenge 😄",
    "1938379": "As a rookie, just like how I didn't know what to do with the Sloth image, I am not sure what I am looking at in this solution and the image 😃\nis the flag value \"SPECTRAL\"? it is barely visible 🤕",
    "1938381": "What are the topics that one need to know to have arrived at this solution? Any resources to understand this?",
    "1938394": "Yes. If you read this paper about stenography [here][1], you will see there are two approaches to hiding text in images. One approach is to hide text in the original image (whether that be the actual image via LSB or the raw text file). The second method is the most common for companies when they watermark their images. In the second method, you convert the image with `fft2` first and then add the text to the transformed spectral image. Then convert the image back to the original space.\n\n[1]: https://docsdrive.com/pdfs/ansinet/jas/2010/2094-2100.pdf",
    "1938428": "Thanks, I will take a look at the paper.",
    "1939260": "congrats @chris62 for your amazing work. keep helping us to learn."
  },
  "source": "meta"
}