Skip to content

Commit c247fbd

Browse files
committed
jupyter jpg compression;move image to data/
1 parent a76a15b commit c247fbd

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

data/tree.jpg

151 KB
Loading

episodes/02-image-basics.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -615,13 +615,23 @@ computing platforms.
615615
> ## Examining actual image sizes (optional, not included in timing)
616616
>
617617
> Let us see the effects of image compression on image size with actual images.
618-
> Open a terminal and navigate to the `code/02-image-basics/`
619-
> directory. This directory contains a simple program, `ws.py` that creates a
620-
> square white image of a specified size, and then saves it as a BMP and as a
621-
> JPEG image.
622-
>
623-
> To create a 5,000 x 5,000 white square, execute the program by typing
624-
> `python ws.py 5000` and then hitting enter. Then, examine the file sizes of
618+
> The following script creates a square white image 5000 X 5000 pixels, and then
619+
> saves it as a BMP and as a JPEG image.
620+
> ~~~
621+
> import skimage.io
622+
> import numpy as np
623+
>
624+
> dim = 5000
625+
>
626+
> img = np.zeros((dim, dim, 3), dtype="uint8")
627+
> img.fill(255)
628+
>
629+
> skimage.io.imsave(fname="data/ws.bmp", arr=img)
630+
> skimage.io.imsave(fname="data/ws.jpg", arr=img)
631+
> ~~~
632+
> {: .language-python}
633+
634+
> Examine the file sizes of
625635
> the two output files, `ws.bmp` and `ws.jpg`. Does the BMP image size
626636
> match our previous prediction? How about the JPEG?
627637
>
@@ -637,7 +647,7 @@ computing platforms.
637647
> ## Comparing lossless versus lossy compression (optional, not included in timing)
638648
>
639649
> Let us see a hands-on example of lossless versus lossy compression. Once again,
640-
> open a terminal and navigate to the `code/02-image-basics/`
650+
> open a terminal and navigate to the `data/`
641651
> directory. The two output images, `ws.bmp` and `ws.jpg`, should still be in the directory,
642652
> along with another image, `tree.jpg`.
643653
>

0 commit comments

Comments
 (0)