Skip to content

Commit e36f5e6

Browse files
committed
add example/mosaic-area.ipynb
1 parent 52eeccd commit e36f5e6

File tree

3 files changed

+6983
-23
lines changed

3 files changed

+6983
-23
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Small de-pixelation Example
22

3-
is in [`example/main.ipynb`](example/main.ipynb)
4-
but best viewed at [`main.ipynb via nbviewer`](https://nbviewer.org/github/KoKuToru/de-pixelate_gaV-O6NPWrI/blob/master/example/main.ipynb)
3+
is in [`example/mosaic-nearest.ipynb`](example/mosaic-nearest.ipynb)
4+
but best viewed at [`mosaic-nearest.ipynb via nbviewer`](https://nbviewer.org/github/KoKuToru/de-pixelate_gaV-O6NPWrI/blob/master/example/mosaic-nearest.ipynb)
55

66
# de-pixelate youtube video gaV-O6NPWrI "Who pays $450 for 2TB?"
77

@@ -25,7 +25,8 @@ The following files are dedicated to the public domain using the Creative Common
2525
* [`v1/extract_frames.sh`](v1/extract_frames.sh)
2626
* [`v2/demosaic.py`](v2/demosaic.py)
2727
* [`v2/extract_frames.sh`](v2/extract_frames.sh)
28-
* [`example/main.ipynb`](example/main.ipynb)
28+
* [`example/mosaic-nearest.ipynb`](example/mosaic-nearest.ipynb)
29+
* [`example/mosaic-area.ipynb`](example/mosaic-area.ipynb)
2930

3031
You can find the full text of the CC0 license online at: <https://creativecommons.org/publicdomain/zero/1.0/>
3132

example/mosaic-area.ipynb

Lines changed: 6950 additions & 0 deletions
Large diffs are not rendered by default.

example/main.ipynb renamed to example/mosaic-nearest.ipynb

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
"id": "335897f5",
66
"metadata": {},
77
"source": [
8-
"# Image Pixelization / De-Pixelization Demo"
8+
"# Image Pixelization / De-Pixelization Demo\n",
9+
"\n",
10+
"This notebook demonstrates how to create a pixelated animation from an original image and then attempt to reconstruct an image from these pixelated blocks.\\\n",
11+
"The pixelation effect is achieved using a `nearest` neighbor filter during downsampling and upsampling of a moving window.\n"
912
]
1013
},
1114
{
@@ -18,7 +21,7 @@
1821
},
1922
{
2023
"cell_type": "code",
21-
"execution_count": 1,
24+
"execution_count": 9,
2225
"id": "20f4dbc1",
2326
"metadata": {},
2427
"outputs": [
@@ -29,7 +32,7 @@
2932
"<PIL.Image.Image image mode=RGBA size=380x380>"
3033
]
3134
},
32-
"execution_count": 1,
35+
"execution_count": 9,
3336
"metadata": {},
3437
"output_type": "execute_result"
3538
}
@@ -55,7 +58,7 @@
5558
},
5659
{
5760
"cell_type": "code",
58-
"execution_count": 2,
61+
"execution_count": 10,
5962
"id": "d3ba5abf",
6063
"metadata": {},
6164
"outputs": [
@@ -114,7 +117,7 @@
114117
},
115118
{
116119
"cell_type": "code",
117-
"execution_count": 3,
120+
"execution_count": null,
118121
"id": "82f5e2d1",
119122
"metadata": {},
120123
"outputs": [
@@ -6138,7 +6141,7 @@
61386141
"<IPython.core.display.HTML object>"
61396142
]
61406143
},
6141-
"execution_count": 3,
6144+
"execution_count": 11,
61426145
"metadata": {},
61436146
"output_type": "execute_result"
61446147
}
@@ -6160,21 +6163,27 @@
61606163
" ...,\n",
61616164
" y_start:y_end,\n",
61626165
" x_start:x_end\n",
6163-
" ] = F.interpolate(original[\n",
6164-
" ...,\n",
6165-
" y_start:y_end:CHUNK_SIZE,\n",
6166-
" x_start:x_end:CHUNK_SIZE\n",
6167-
" ], size=(AREA_SIZE, AREA_SIZE), mode='nearest')\n",
6166+
" ] = F.interpolate(\n",
6167+
" F.interpolate(\n",
6168+
" original[\n",
6169+
" ...,\n",
6170+
" y_start:y_end,\n",
6171+
" x_start:x_end\n",
6172+
" ],\n",
6173+
" size=(AREA_SIZE // CHUNK_SIZE, AREA_SIZE // CHUNK_SIZE),\n",
6174+
" mode='nearest' # use NEAREST-FILTER\n",
6175+
" ),\n",
6176+
" size=(AREA_SIZE, AREA_SIZE),\n",
6177+
" mode='nearest'\n",
6178+
" )\n",
61686179
"\n",
61696180
"def display_frames(title, frames):\n",
61706181
" fig, ax = plt.subplots()\n",
61716182
" ims = []\n",
61726183
" for frame in frames:\n",
6173-
" # Assuming 'frame[0]' is your image data that can be processed by TF.to_pil_image\n",
61746184
" pil_image = TF.to_pil_image(TF.vflip(frame))\n",
6175-
" # Append the image object returned by imshow to the list\n",
61766185
" im_artist = ax.imshow(pil_image, animated=True)\n",
6177-
" ims.append([im_artist]) # ims should be a list of lists of artists\n",
6186+
" ims.append([im_artist])\n",
61786187
"\n",
61796188
" import matplotlib.animation as animation\n",
61806189
" ani = animation.ArtistAnimation(fig, ims, interval=50, blit=True, repeat_delay=1000)\n",
@@ -6208,7 +6217,7 @@
62086217
},
62096218
{
62106219
"cell_type": "code",
6211-
"execution_count": 4,
6220+
"execution_count": 12,
62126221
"id": "a956c6f5",
62136222
"metadata": {},
62146223
"outputs": [
@@ -8121,7 +8130,7 @@
81218130
"<IPython.core.display.HTML object>"
81228131
]
81238132
},
8124-
"execution_count": 4,
8133+
"execution_count": 12,
81258134
"metadata": {},
81268135
"output_type": "execute_result"
81278136
}
@@ -8158,7 +8167,7 @@
81588167
},
81598168
{
81608169
"cell_type": "code",
8161-
"execution_count": 7,
8170+
"execution_count": 13,
81628171
"id": "276d5775",
81638172
"metadata": {},
81648173
"outputs": [
@@ -8169,7 +8178,7 @@
81698178
"<PIL.Image.Image image mode=RGBA size=380x380>"
81708179
]
81718180
},
8172-
"execution_count": 7,
8181+
"execution_count": 13,
81738182
"metadata": {},
81748183
"output_type": "execute_result"
81758184
}
@@ -8194,7 +8203,7 @@
81948203
},
81958204
{
81968205
"cell_type": "code",
8197-
"execution_count": 8,
8206+
"execution_count": 14,
81988207
"id": "24bb6abb",
81998208
"metadata": {},
82008209
"outputs": [
@@ -8205,7 +8214,7 @@
82058214
"<PIL.Image.Image image mode=RGBA size=380x380>"
82068215
]
82078216
},
8208-
"execution_count": 8,
8217+
"execution_count": 14,
82098218
"metadata": {},
82108219
"output_type": "execute_result"
82118220
}

0 commit comments

Comments
 (0)