Skip to content

Commit fe75d35

Browse files
committed
consistently use named arguments
1 parent 013686a commit fe75d35

File tree

7 files changed

+31
-31
lines changed

7 files changed

+31
-31
lines changed

episodes/03-skimage-images.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ import skimage.io
374374
import skimage.color
375375

376376
# read input image
377-
image = skimage.io.imread("data/chair.jpg")
377+
image = skimage.io.imread(fname="data/chair.jpg")
378378

379379
# display original image
380380
fig, ax = plt.subplots()
@@ -398,7 +398,7 @@ import skimage.io
398398
import skimage.color
399399

400400
# read input image, based on filename parameter
401-
image = skimage.io.imread("data/chair.jpg", as_gray=True)
401+
image = skimage.io.imread(fname="data/chair.jpg", as_gray=True)
402402

403403
# display grayscale image
404404
fig, ax = plt.subplots()

episodes/04-drawing.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ import matplotlib.pyplot as plt
6666
%matplotlib widget
6767
6868
# Load and display the original image
69-
image = skimage.io.imread("data/maize-seedlings.tif")
69+
image = skimage.io.imread(fname="data/maize-seedlings.tif")
7070
7171
fig, ax = plt.subplots()
7272
plt.imshow(image)
@@ -201,7 +201,7 @@ The function returns the rectangle as row (`rr`) and column (`cc`) coordinate ar
201201
> >
202202
> > ~~~
203203
> > # Draw a blue circle with centre (200, 300) in (y, x) coordinates, and radius 100
204-
> > rr, cc = skimage.draw.disk((200, 300), 100, shape=image.shape[0:2])
204+
> > rr, cc = skimage.draw.disk(center=(200, 300), radius=100, shape=image.shape[0:2])
205205
> > image[rr, cc] = (0, 0, 255)
206206
> > ~~~
207207
> > {: .language-python}
@@ -210,7 +210,7 @@ The function returns the rectangle as row (`rr`) and column (`cc`) coordinate ar
210210
> >
211211
> > ~~~
212212
> > # Draw a green line from (400, 200) to (500, 700) in (y, x) coordinates
213-
> > rr, cc = skimage.draw.line(400, 200, 500, 700)
213+
> > rr, cc = skimage.draw.line(r0=400, c0=200, r1=500, c1=700)
214214
> > image[rr, cc] = (0, 255, 0)
215215
> > ~~~
216216
> > {: .language-python}
@@ -239,7 +239,7 @@ The function returns the rectangle as row (`rr`) and column (`cc`) coordinate ar
239239
> >
240240
> > # draw a blue circle at a random location 15 times
241241
> > for i in range(15):
242-
> > rr, cc = skimage.draw.disk((
242+
> > rr, cc = skimage.draw.disk(center=(
243243
> > random.randrange(600),
244244
> > random.randrange(800)),
245245
> > radius=50,
@@ -270,7 +270,7 @@ The function returns the rectangle as row (`rr`) and column (`cc`) coordinate ar
270270
> > x = random.random()
271271
> > if x < 0.33:
272272
> > # draw a blue circle at a random location
273-
> > rr, cc = skimage.draw.disk((
273+
> > rr, cc = skimage.draw.disk(center=(
274274
> > random.randrange(600),
275275
> > random.randrange(800)),
276276
> > radius=50,
@@ -280,10 +280,10 @@ The function returns the rectangle as row (`rr`) and column (`cc`) coordinate ar
280280
> > elif x < 0.66:
281281
> > # draw a green line at a random location
282282
> > rr, cc = skimage.draw.line(
283-
> > random.randrange(600),
284-
> > random.randrange(800),
285-
> > random.randrange(600),
286-
> > random.randrange(800),
283+
> > r0=random.randrange(600),
284+
> > c0=random.randrange(800),
285+
> > r1=random.randrange(600),
286+
> > c1=random.randrange(800),
287287
> > )
288288
> > color = (0, 255, 0)
289289
> > else:
@@ -393,7 +393,7 @@ The resulting masked image should look like this:
393393
> >
394394
> > ~~~
395395
> > # Load the image
396-
> > image = skimage.io.imread("data/remote-control.jpg")
396+
> > image = skimage.io.imread(fname="data/remote-control.jpg")
397397
> >
398398
> > # Create the basic mask
399399
> > mask = np.ones(shape=image.shape[0:2], dtype="bool")
@@ -420,7 +420,7 @@ The resulting masked image should look like this:
420420
>
421421
> ~~~
422422
> # Load the image
423-
> image = skimage.io.imread("data/wellplate-01.jpg")
423+
> image = skimage.io.imread(fname="data/wellplate-01.jpg")
424424
>
425425
> # Display the image
426426
> fig, ax = plt.subplots()
@@ -449,7 +449,7 @@ The resulting masked image should look like this:
449449
> >
450450
> > ~~~
451451
> > # read in original image
452-
> > image = skimage.io.imread("data/wellplate-01.jpg")
452+
> > image = skimage.io.imread(fname="data/wellplate-01.jpg")
453453
> >
454454
> > # create the mask image
455455
> > mask = np.ones(shape=image.shape[0:2], dtype="bool")
@@ -463,7 +463,7 @@ The resulting masked image should look like this:
463463
> > y = int(coordinates[1])
464464
> >
465465
> > # ... and drawing a circle on the mask
466-
> > rr, cc = skimage.draw.disk((y, x), radius=16, shape=image.shape[0:2])
466+
> > rr, cc = skimage.draw.disk(center=(y, x), radius=16, shape=image.shape[0:2])
467467
> > mask[rr, cc] = False
468468
> >
469469
> > # apply the mask
@@ -506,7 +506,7 @@ The resulting masked image should look like this:
506506
> >
507507
> > ~~~
508508
> > # read in original image
509-
> > image = skimage.io.imread("data/wellplate-01.jpg")
509+
> > image = skimage.io.imread(fname="data/wellplate-01.jpg")
510510
> >
511511
> > # create the mask image
512512
> > mask = np.ones(shape=image.shape[0:2], dtype="bool")
@@ -529,7 +529,7 @@ The resulting masked image should look like this:
529529
> > for col in range(8):
530530
> >
531531
> > # ... and drawing a circle on the mask
532-
> > rr, cc = skimage.draw.disk((y, x), radius=16, shape=image.shape[0:2])
532+
> > rr, cc = skimage.draw.disk(center=(y, x), radius=16, shape=image.shape[0:2])
533533
> > mask[rr, cc] = False
534534
> > x += deltaX
535535
> > # after one complete row, move to next row

episodes/05-creating-histograms.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ it produces this histogram:
197197
> > import skimage.draw
198198
> >
199199
> > # read the image as grayscale from the outset
200-
> > image = skimage.io.imread("data/plant-seedling.jpg", as_gray=True)
200+
> > image = skimage.io.imread(fname="data/plant-seedling.jpg", as_gray=True)
201201
> >
202202
> > # display the image
203203
> > fig, ax = plt.subplots()
@@ -247,7 +247,7 @@ A program to create colour histograms starts in a familiar way:
247247
248248
~~~
249249
# read original image, in full color
250-
image = skimage.io.imread("data/plant-seedling.jpg")
250+
image = skimage.io.imread(fname="data/plant-seedling.jpg")
251251

252252
# display the image
253253
fig, ax = plt.subplots()
@@ -376,7 +376,7 @@ Finally we label our axes and display the histogram, shown here:
376376
>
377377
> ~~~
378378
> # read the image
379-
> image = skimage.io.imread("data/wellplate-02.tif")
379+
> image = skimage.io.imread(fname="data/wellplate-02.tif")
380380
>
381381
> # display the image
382382
> fig, ax = plt.subplots()
@@ -409,7 +409,7 @@ Finally we label our axes and display the histogram, shown here:
409409
> > ~~~
410410
> > # create a circular mask to select the 7th well in the first row
411411
> > mask = np.zeros(shape=image.shape[0:2], dtype="bool")
412-
> > circle = skimage.draw.disk((240, 1053), radius=49, shape=image.shape[0:2])
412+
> > circle = skimage.draw.disk(center=(240, 1053), radius=49, shape=image.shape[0:2])
413413
> > mask[circle] = 1
414414
> >
415415
> > # just for display:

episodes/06-blurring.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ import matplotlib.pyplot as plt
235235
import skimage.filters
236236
%matplotlib widget
237237

238-
image = skimage.io.imread("data/gaussian-original.png")
238+
image = skimage.io.imread(fname="data/gaussian-original.png")
239239

240240
# display the image
241241
fig, ax = plt.subplots()

episodes/07-thresholding.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ we have seen before in
311311
[the _Image Representation in skimage_ episode]({{ page.root }}{% link _episodes/03-skimage-images.md %}).
312312
313313
~~~
314-
image = skimage.io.imread("data/maize-root-cluster.jpg")
314+
image = skimage.io.imread(fname="data/maize-root-cluster.jpg")
315315

316316
fig, ax = plt.subplots()
317317
plt.imshow(image)
@@ -503,7 +503,7 @@ For example, for the file `data/trial-016.jpg` and a sigma value of 1.5,
503503
we would call the function like this:
504504
505505
~~~
506-
measure_root_mass("data/trial-016.jpg", sigma=1.5)
506+
measure_root_mass(filename="data/trial-016.jpg", sigma=1.5)
507507
~~~
508508
{: .language-python}
509509
@@ -524,7 +524,7 @@ end with the **.jpg** suffix.
524524
~~~
525525
all_files = glob.glob("data/trial-*.jpg")
526526
for filename in all_files:
527-
density = measure_root_mass(filename, sigma=1.5)
527+
density = measure_root_mass(filename=filename, sigma=1.5)
528528
# output in format suitable for .csv
529529
print(filename, density, sep=",")
530530
~~~
@@ -644,7 +644,7 @@ data/trial-293.jpg,0.13607895611702128
644644
> >
645645
> > all_files = glob.glob("data/trial-*.jpg")
646646
> > for filename in all_files:
647-
> > density = enhanced_root_mass(filename, sigma=1.5)
647+
> > density = enhanced_root_mass(filename=filename, sigma=1.5)
648648
> > # output in format suitable for .csv
649649
> > print(filename, density, sep=",")
650650
> > ~~~
@@ -690,7 +690,7 @@ data/trial-293.jpg,0.13607895611702128
690690
> > ## Solution
691691
> > Here is the code to create the grayscale histogram:
692692
> > ~~~
693-
> > image = skimage.io.imread("data/colonies-01.tif")
693+
> > image = skimage.io.imread(fname="data/colonies-01.tif")
694694
> > gray_image = skimage.color.rgb2gray(image)
695695
> > blurred_image = skimage.filters.gaussian(gray_image, sigma=1.0)
696696
> > histogram, bin_edges = np.histogram(blurred_image, bins=256, range=(0.0, 1.0))

episodes/08-connected-components.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ We can call the above function `connected_components` and
292292
display the labeled image like so:
293293
294294
~~~
295-
labeled_image, count = connected_components("data/shapes-01.jpg", sigma=2.0, t=0.9, connectivity=2)
295+
labeled_image, count = connected_components(filename="data/shapes-01.jpg", sigma=2.0, t=0.9, connectivity=2)
296296

297297
fig, ax = plt.subplots()
298298
plt.imshow(labeled_image)
@@ -683,7 +683,7 @@ This will produce the output
683683
> > display the resulting labeled image:
684684
> >
685685
> > ~~~
686-
> > labeled_image, count = enhanced_connected_components("data/shapes-01.jpg", sigma=2.0, t=0.9,
686+
> > labeled_image, count = enhanced_connected_components(filename="data/shapes-01.jpg", sigma=2.0, t=0.9,
687687
> > connectivity=2, min_area=min_area)
688688
> > colored_label_image = skimage.color.label2rgb(labeled_image, bg_label=0)
689689
> >

episodes/09-challenges.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ and `data/colonies-03.tif`.
6363
> > import matplotlib.pyplot as plt
6464
> > %matplotlib widget
6565
> >
66-
> > bacteria_image = skimage.io.imread("data/colonies-01.tif")
66+
> > bacteria_image = skimage.io.imread(fname="data/colonies-01.tif")
6767
> >
6868
> > # display the image
6969
> > fig, ax = plt.subplots()
@@ -177,7 +177,7 @@ and `data/colonies-03.tif`.
177177
> >
178178
> > ~~~
179179
> > for image_filename in ["data/colonies-01.tif", "data/colonies-02.tif", "data/colonies-03.tif"]:
180-
> > count_colonies(image_filename)
180+
> > count_colonies(image_filename=image_filename)
181181
> > ~~~
182182
> > {: .language-python}
183183
> >

0 commit comments

Comments
 (0)