{
  "id": 77279,
  "title": "How do we handle grayscale images?",
  "url": "/competitions/humpback-whale-identification/discussion/77279",
  "author_name": "JYAhn",
  "post_date": "2019-01-11T04:46:47.953000",
  "votes": 2,
  "comment_count": 2,
  "views": 0,
  "content": "<p>Hi all,\nOf the 25,000 images, over 3,000 images are gray-scale image (<a href=\"https://www.kaggle.com/jy93630/separating-gray-and-color-images\">https://www.kaggle.com/jy93630/separating-gray-and-color-images</a>).</p>\n\n<p>Many people do preprocessing using the code below.</p>\n\n<pre><code>def prepareImages(data, m, dataset):\n    print(\"Preparing images\")\n    X_train = np.zeros((m, 100, 100, 3))\n    count = 0\n\n    for fig in data['Image']:\n        #load images into images of size 100x100x3\n        img = image.load_img(\"../input/\"+dataset+\"/\"+fig, target_size=(100, 100, 3))\n        x = image.img_to_array(img)\n        x = preprocess_input(x)\n\n        X_train[count] = x\n        if (count%500 == 0):\n            print(\"Processing image: \", count+1, \", \", fig)\n        count += 1\n\n    return X_train\n</code></pre>\n\n<p>\"target_size=(100, 100, 3)\"  This option extend the grayscale image to three RGB channels?</p>\n\n<p>Isn't it a problem to train grayscale and color images together in terms of prediction performance?</p>\n\n<p>Thanks.</p>",
  "messages": [
    {
      "id": 454058,
      "postDate": "2019-01-11T04:46:47.953Z",
      "content": "<p>Hi all,\nOf the 25,000 images, over 3,000 images are gray-scale image (<a href=\"https://www.kaggle.com/jy93630/separating-gray-and-color-images\">https://www.kaggle.com/jy93630/separating-gray-and-color-images</a>).</p>\n\n<p>Many people do preprocessing using the code below.</p>\n\n<pre><code>def prepareImages(data, m, dataset):\n    print(\"Preparing images\")\n    X_train = np.zeros((m, 100, 100, 3))\n    count = 0\n\n    for fig in data['Image']:\n        #load images into images of size 100x100x3\n        img = image.load_img(\"../input/\"+dataset+\"/\"+fig, target_size=(100, 100, 3))\n        x = image.img_to_array(img)\n        x = preprocess_input(x)\n\n        X_train[count] = x\n        if (count%500 == 0):\n            print(\"Processing image: \", count+1, \", \", fig)\n        count += 1\n\n    return X_train\n</code></pre>\n\n<p>\"target_size=(100, 100, 3)\"  This option extend the grayscale image to three RGB channels?</p>\n\n<p>Isn't it a problem to train grayscale and color images together in terms of prediction performance?</p>\n\n<p>Thanks.</p>",
      "rawMarkdown": "Hi all,\nOf the 25,000 images, over 3,000 images are gray-scale image (https://www.kaggle.com/jy93630/separating-gray-and-color-images).\n\nMany people do preprocessing using the code below.\n\n    def prepareImages(data, m, dataset):\n        print(\"Preparing images\")\n        X_train = np.zeros((m, 100, 100, 3))\n        count = 0\n        \n        for fig in data['Image']:\n            #load images into images of size 100x100x3\n            img = image.load_img(\"../input/\"+dataset+\"/\"+fig, target_size=(100, 100, 3))\n            x = image.img_to_array(img)\n            x = preprocess_input(x)\n    \n            X_train[count] = x\n            if (count%500 == 0):\n                print(\"Processing image: \", count+1, \", \", fig)\n            count += 1\n        \n        return X_train\n\n\"target_size=(100, 100, 3)\"  This option extend the grayscale image to three RGB channels?\n\nIsn't it a problem to train grayscale and color images together in terms of prediction performance?\n\nThanks.\n",
      "votes": 2
    },
    {
      "id": 454955,
      "postDate": "2019-01-12T16:06:51.330Z",
      "content": "<p>Hey,</p>\n\n<p>I experienced a fairly good perfomance on a subset of training data by reducing the images to grayscale This way, you can increase the batch size of your neural networks or other parameters like the image size which is likely to help boost the performance of your model, as it can find higher resolution morphologies of the humpbacks.</p>\n\n<p>I joint this competition somewhat later, so maybe, others have studied the differences in the RGB channels in more detail and can share more insight?</p>\n\n<p>Have you trained a network on grayscale and RGB images and found significant differences?</p>\n\n<p>Cheers,\nJeffrey</p>",
      "rawMarkdown": "Hey,\n\nI experienced a fairly good perfomance on a subset of training data by reducing the images to grayscale This way, you can increase the batch size of your neural networks or other parameters like the image size which is likely to help boost the performance of your model, as it can find higher resolution morphologies of the humpbacks.\n\nI joint this competition somewhat later, so maybe, others have studied the differences in the RGB channels in more detail and can share more insight?\n\nHave you trained a network on grayscale and RGB images and found significant differences?\n\nCheers,\nJeffrey"
    },
    {
      "id": 468914,
      "postDate": "2019-02-10T03:02:23.373Z",
      "rawMarkdown": "",
      "isDeleted": true
    }
  ],
  "comments": [
    {
      "id": 454955,
      "author_name": "Jeffrey Kotula",
      "author_url": "",
      "post_date": "2019-01-12T16:06:51.330000",
      "content": "<p>Hey,</p>\n\n<p>I experienced a fairly good perfomance on a subset of training data by reducing the images to grayscale This way, you can increase the batch size of your neural networks or other parameters like the image size which is likely to help boost the performance of your model, as it can find higher resolution morphologies of the humpbacks.</p>\n\n<p>I joint this competition somewhat later, so maybe, others have studied the differences in the RGB channels in more detail and can share more insight?</p>\n\n<p>Have you trained a network on grayscale and RGB images and found significant differences?</p>\n\n<p>Cheers,\nJeffrey</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 468914,
      "author_name": "",
      "author_url": "",
      "post_date": "2019-02-10T03:02:23.373000",
      "content": "",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "454058": "Hi all,\nOf the 25,000 images, over 3,000 images are gray-scale image (https://www.kaggle.com/jy93630/separating-gray-and-color-images).\n\nMany people do preprocessing using the code below.\n\n    def prepareImages(data, m, dataset):\n        print(\"Preparing images\")\n        X_train = np.zeros((m, 100, 100, 3))\n        count = 0\n        \n        for fig in data['Image']:\n            #load images into images of size 100x100x3\n            img = image.load_img(\"../input/\"+dataset+\"/\"+fig, target_size=(100, 100, 3))\n            x = image.img_to_array(img)\n            x = preprocess_input(x)\n    \n            X_train[count] = x\n            if (count%500 == 0):\n                print(\"Processing image: \", count+1, \", \", fig)\n            count += 1\n        \n        return X_train\n\n\"target_size=(100, 100, 3)\"  This option extend the grayscale image to three RGB channels?\n\nIsn't it a problem to train grayscale and color images together in terms of prediction performance?\n\nThanks.\n",
    "454955": "Hey,\n\nI experienced a fairly good perfomance on a subset of training data by reducing the images to grayscale This way, you can increase the batch size of your neural networks or other parameters like the image size which is likely to help boost the performance of your model, as it can find higher resolution morphologies of the humpbacks.\n\nI joint this competition somewhat later, so maybe, others have studied the differences in the RGB channels in more detail and can share more insight?\n\nHave you trained a network on grayscale and RGB images and found significant differences?\n\nCheers,\nJeffrey",
    "468914": ""
  }
}