{
  "id": 181075,
  "title": "Different ways to resize 3D images",
  "url": "/competitions/osic-pulmonary-fibrosis-progression/discussion/181075",
  "author_name": "",
  "post_date": "2020-09-07T13:59:32.215446200Z",
  "votes": 1,
  "comment_count": 1,
  "views": 0,
  "content": "<p>Hi,<br>\nI am building a model with 3D convolutional layers. I create 3D images for each patient from the DICOM images. At the moment, to get a constant size, I am resizing each slices and then again on a different axe to get the desired size. I would like to know if there is special ways to resize for 3D images. Tanks in advance for the answers.</p>",
  "messages": [
    {
      "id": "1001715",
      "postDate": "09/07/2020 13:59:32",
      "content": "<p>Hi,<br>\nI am building a model with 3D convolutional layers. I create 3D images for each patient from the DICOM images. At the moment, to get a constant size, I am resizing each slices and then again on a different axe to get the desired size. I would like to know if there is special ways to resize for 3D images. Tanks in advance for the answers.</p>",
      "rawMarkdown": "Hi,\nI am building a model with 3D convolutional layers. I create 3D images for each patient from the DICOM images. At the moment, to get a constant size, I am resizing each slices and then again on a different axe to get the desired size. I would like to know if there is special ways to resize for 3D images. Tanks in advance for the answers.",
      "votes": null
    },
    {
      "id": "1002264",
      "postDate": "09/08/2020 02:00:04",
      "content": "<p>follow code from Carlos Souza's kernel：<a href=\"https://www.kaggle.com/carlossouza/end-to-end-model-ct-scans-tabular\" target=\"_blank\">https://www.kaggle.com/carlossouza/end-to-end-model-ct-scans-tabular</a><br>\nand work for me <br>\n`<br>\nclass Resize:<br>\n    def <strong>init</strong>(self, output_size):<br>\n        assert isinstance(output_size, tuple)<br>\n        self.output_size = output_size</p>\n<pre><code>def __call__(self, sample):\n    image = sample[\"image\"]\n    resize_factor = np.array(self.output_size) / np.array(image.shape)\n    image = zoom(image, resize_factor, mode='nearest')\n    return {\n        'features': sample['features'],\n        'image': image,\n        'metadata': sample['metadata'],\n        'target': sample['target']\n    }\n</code></pre>\n<p>`</p>",
      "rawMarkdown": "follow code from Carlos Souza's kernel：https://www.kaggle.com/carlossouza/end-to-end-model-ct-scans-tabular\nand work for me \n`\nclass Resize:\n    def __init__(self, output_size):\n        assert isinstance(output_size, tuple)\n        self.output_size = output_size\n\n    def __call__(self, sample):\n        image = sample[\"image\"]\n        resize_factor = np.array(self.output_size) / np.array(image.shape)\n        image = zoom(image, resize_factor, mode='nearest')\n        return {\n            'features': sample['features'],\n            'image': image,\n            'metadata': sample['metadata'],\n            'target': sample['target']\n        }\n`",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1002264,
      "author_name": "tantai",
      "author_url": "",
      "post_date": "09/08/2020 02:00:04",
      "content": "<p>follow code from Carlos Souza's kernel：<a href=\"https://www.kaggle.com/carlossouza/end-to-end-model-ct-scans-tabular\" target=\"_blank\">https://www.kaggle.com/carlossouza/end-to-end-model-ct-scans-tabular</a><br>\nand work for me <br>\n`<br>\nclass Resize:<br>\n    def <strong>init</strong>(self, output_size):<br>\n        assert isinstance(output_size, tuple)<br>\n        self.output_size = output_size</p>\n<pre><code>def __call__(self, sample):\n    image = sample[\"image\"]\n    resize_factor = np.array(self.output_size) / np.array(image.shape)\n    image = zoom(image, resize_factor, mode='nearest')\n    return {\n        'features': sample['features'],\n        'image': image,\n        'metadata': sample['metadata'],\n        'target': sample['target']\n    }\n</code></pre>\n<p>`</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1001715": "Hi,\nI am building a model with 3D convolutional layers. I create 3D images for each patient from the DICOM images. At the moment, to get a constant size, I am resizing each slices and then again on a different axe to get the desired size. I would like to know if there is special ways to resize for 3D images. Tanks in advance for the answers.",
    "1002264": "follow code from Carlos Souza's kernel：https://www.kaggle.com/carlossouza/end-to-end-model-ct-scans-tabular\nand work for me \n`\nclass Resize:\n    def __init__(self, output_size):\n        assert isinstance(output_size, tuple)\n        self.output_size = output_size\n\n    def __call__(self, sample):\n        image = sample[\"image\"]\n        resize_factor = np.array(self.output_size) / np.array(image.shape)\n        image = zoom(image, resize_factor, mode='nearest')\n        return {\n            'features': sample['features'],\n            'image': image,\n            'metadata': sample['metadata'],\n            'target': sample['target']\n        }\n`"
  },
  "source": "meta"
}