From 60d50aa9d2033745dec340c5f8fbde251e98968e Mon Sep 17 00:00:00 2001 From: udlbook <110402648+udlbook@users.noreply.github.com> Date: Thu, 1 Jan 2026 15:33:00 -0500 Subject: [PATCH] Created using Colab --- .../10_4_Downsampling_and_Upsampling.ipynb | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/Notebooks/Chap10/10_4_Downsampling_and_Upsampling.ipynb b/Notebooks/Chap10/10_4_Downsampling_and_Upsampling.ipynb index 0241ec6..8170972 100644 --- a/Notebooks/Chap10/10_4_Downsampling_and_Upsampling.ipynb +++ b/Notebooks/Chap10/10_4_Downsampling_and_Upsampling.ipynb @@ -4,7 +4,6 @@ "metadata": { "colab": { "provenance": [], - "authorship_tag": "ABX9TyMbSR8fzpXvO6TIQdO7bI0H", "include_colab_link": true }, "kernelspec": { @@ -71,9 +70,9 @@ { "cell_type": "code", "source": [ - "def subsample(x_in):\n", + "def downsample(x_in):\n", " x_out = np.zeros(( int(np.ceil(x_in.shape[0]/2)), int(np.ceil(x_in.shape[1]/2)) ))\n", - " # TODO -- write the subsampling routine\n", + " # TODO -- write the downsampling routine\n", " # Replace this line\n", " x_out = x_out\n", "\n", @@ -91,8 +90,8 @@ "source": [ "print(\"Original:\")\n", "print(orig_4_4)\n", - "print(\"Subsampled:\")\n", - "print(subsample(orig_4_4))" + "print(\"Downsampled:\")\n", + "print(downsample(orig_4_4))" ], "metadata": { "id": "O_i0y72_JwGZ" @@ -127,24 +126,24 @@ "image = Image.open('test_image.png')\n", "# convert image to numpy array\n", "data = asarray(image)\n", - "data_subsample = subsample(data);\n", + "data_downsample = downsample(data);\n", "\n", "plt.figure(figsize=(5,5))\n", "plt.imshow(data, cmap='gray')\n", "plt.show()\n", "\n", "plt.figure(figsize=(5,5))\n", - "plt.imshow(data_subsample, cmap='gray')\n", + "plt.imshow(data_downsample, cmap='gray')\n", "plt.show()\n", "\n", - "data_subsample2 = subsample(data_subsample)\n", + "data_downsample2 = downsample(data_downsample)\n", "plt.figure(figsize=(5,5))\n", - "plt.imshow(data_subsample2, cmap='gray')\n", + "plt.imshow(data_downsample2, cmap='gray')\n", "plt.show()\n", "\n", - "data_subsample3 = subsample(data_subsample2)\n", + "data_downsample3 = downsample(data_downsample2)\n", "plt.figure(figsize=(5,5))\n", - "plt.imshow(data_subsample3, cmap='gray')\n", + "plt.imshow(data_downsample3, cmap='gray')\n", "plt.show()" ], "metadata": { @@ -345,11 +344,11 @@ { "cell_type": "code", "source": [ - "# Let's re-upsample, sub-sampled rick\n", - "data_duplicate = duplicate(data_subsample3);\n", + "# Let's re-upsample, downsampled rick\n", + "data_duplicate = duplicate(data_downsample3);\n", "\n", "plt.figure(figsize=(5,5))\n", - "plt.imshow(data_subsample3, cmap='gray')\n", + "plt.imshow(data_downsample3, cmap='gray')\n", "plt.show()\n", "\n", "plt.figure(figsize=(5,5))\n", @@ -388,7 +387,7 @@ "# The input x_high_res is the original high res image, from which you can deduce the position of the maximum index\n", "def max_unpool(x_in, x_high_res):\n", " x_out = np.zeros(( x_in.shape[0]*2, x_in.shape[1]*2 ))\n", - " # TODO -- write the subsampling routine\n", + " # TODO -- write the unpooling routine\n", " # Replace this line\n", " x_out = x_out\n", "\n", @@ -417,7 +416,7 @@ { "cell_type": "code", "source": [ - "# Let's re-upsample, sub-sampled rick\n", + "# Let's re-upsample, down-sampled rick\n", "data_max_unpool= max_unpool(data_maxpool3,data_maxpool2);\n", "\n", "plt.figure(figsize=(5,5))\n", @@ -489,7 +488,7 @@ { "cell_type": "code", "source": [ - "# Let's re-upsample, sub-sampled rick\n", + "# Let's re-upsample, down-sampled rick\n", "data_bilinear = bilinear(data_meanpool3);\n", "\n", "plt.figure(figsize=(5,5))\n", @@ -517,4 +516,4 @@ "outputs": [] } ] -} +} \ No newline at end of file