{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Rescale, resize, and downscale\n\n`Rescale` operation resizes an image by a given scaling factor. The scaling\nfactor can either be a single floating point value, or multiple values - one\nalong each axis.\n\n`Resize` serves the same purpose, but allows to specify an output image shape\ninstead of a scaling factor.\n\nNote that when down-sampling an image, `resize` and `rescale` should perform\nGaussian smoothing to avoid aliasing artifacts. See the `anti_aliasing` and\n`anti_aliasing_sigma` arguments to these functions.\n\n`Downscale` serves the purpose of down-sampling an n-dimensional image by\ninteger factors using the local mean on the elements of each block of the size\nfactors given as a parameter to the function.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\n\nfrom skimage import data, color\nfrom skimage.transform import rescale, resize, downscale_local_mean\n\nimage = color.rgb2gray(data.astronaut())\n\nimage_rescaled = rescale(image, 0.25, anti_aliasing=False)\nimage_resized = resize(\n    image, (image.shape[0] // 4, image.shape[1] // 4), anti_aliasing=True\n)\nimage_downscaled = downscale_local_mean(image, (4, 3))\n\nfig, axes = plt.subplots(nrows=2, ncols=2)\n\nax = axes.ravel()\n\nax[0].imshow(image, cmap='gray')\nax[0].set_title(\"Original image\")\n\nax[1].imshow(image_rescaled, cmap='gray')\nax[1].set_title(\"Rescaled image (aliasing)\")\n\nax[2].imshow(image_resized, cmap='gray')\nax[2].set_title(\"Resized image (no aliasing)\")\n\nax[3].imshow(image_downscaled, cmap='gray')\nax[3].set_title(\"Downscaled image (no aliasing)\")\n\nax[0].set_xlim(0, 512)\nax[0].set_ylim(512, 0)\nplt.tight_layout()\nplt.show()"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.12.12"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}