Skip to content

Commit

Permalink
markdown source builds
Browse files Browse the repository at this point in the history
Auto-generated via `{sandpaper}`
Source  : bfaf89e
Branch  : main
Author  : Kimberly Meechan <[email protected]>
Time    : 2025-02-09 16:51:23 +0000
Message : Merge pull request #338 from nanosec/size

Use ndarray.size instead of multiplying
  • Loading branch information
actions-user committed Feb 9, 2025
1 parent c97f859 commit f0b23cd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
13 changes: 3 additions & 10 deletions 07-thresholding.md
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,7 @@ def measure_root_mass(filename, sigma=1.0):

# determine root mass ratio
root_pixels = np.count_nonzero(binary_mask)
w = binary_mask.shape[1]
h = binary_mask.shape[0]
density = root_pixels / (w * h)
density = root_pixels / binary_mask.size

return density
```
Expand All @@ -499,11 +497,8 @@ Recall that in the `binary_mask`, every pixel has either a value of
zero (black/background) or one (white/foreground).
We want to count the number of white pixels,
which can be accomplished with a call to the NumPy function `np.count_nonzero`.
Then we determine the width and height of the image by using
the elements of `binary_mask.shape`
(that is, the dimensions of the NumPy array that stores the image).
Finally, the density ratio is calculated by dividing the number of white pixels
by the total number of pixels `w*h` in the image.
by the total number of pixels `binary_mask.size` in the image.
The function returns then root density of the image.

We can call this function with any filename and
Expand Down Expand Up @@ -650,9 +645,7 @@ def enhanced_root_mass(filename, sigma):

# determine root mass ratio
root_pixels = np.count_nonzero(binary_mask)
w = binary_mask.shape[1]
h = binary_mask.shape[0]
density = root_pixels / (w * h)
density = root_pixels / binary_mask.size

return density

Expand Down
2 changes: 1 addition & 1 deletion md5sum.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"episodes/04-drawing.md" "48b42ee384b5b907d9f9b93ad0e98ce8" "site/built/04-drawing.md" "2024-06-07"
"episodes/05-creating-histograms.md" "4abbd123ba97d63c795398be6f6b7621" "site/built/05-creating-histograms.md" "2024-03-14"
"episodes/06-blurring.md" "894ff33379584a8ee777f779564d5b01" "site/built/06-blurring.md" "2024-06-18"
"episodes/07-thresholding.md" "4d34b89c8cd33cb6bb54103f805a39b9" "site/built/07-thresholding.md" "2024-03-12"
"episodes/07-thresholding.md" "512a1806b8061dded3a68871e7bcdfe9" "site/built/07-thresholding.md" "2025-02-09"
"episodes/08-connected-components.md" "f599af69b770c7234a4e7d4a06a7f6dd" "site/built/08-connected-components.md" "2024-11-13"
"episodes/09-challenges.md" "3e95485b1bae2c37538830225ea26598" "site/built/09-challenges.md" "2024-03-12"
"instructors/instructor-notes.md" "e8e378a5dfaec7b2873d788be85003ce" "site/built/instructor-notes.md" "2024-06-18"
Expand Down

0 comments on commit f0b23cd

Please sign in to comment.