Skip to content

Commit 3440cba

Browse files
committed
markdown source builds
Auto-generated via {sandpaper} Source : 00d5593 Branch : main Author : Ulf Schiller <uschille@users.noreply.github.com> Time : 2023-08-27 02:23:24 +0000 Message : Merge pull request #294 from mkcor/proof-ep-blur Proofread episode 6 (Blurring Images).
1 parent 68be0d4 commit 3440cba

File tree

2 files changed

+32
-33
lines changed

2 files changed

+32
-33
lines changed

06-blurring.md

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ In this episode, we will learn how to use scikit-image functions to blur images.
2121

2222
When processing an image, we are often interested in identifying objects
2323
represented within it so that we can perform some further analysis of these
24-
objects e.g. by counting them, measuring their sizes, etc.
24+
objects, e.g., by counting them, measuring their sizes, etc.
2525
An important concept associated with the identification of objects in an image
2626
is that of *edges*: the lines that represent a transition from one group of
2727
similar pixels in the image to another different group.
@@ -33,7 +33,7 @@ When we blur an image,
3333
we make the colour transition from one side of an edge in the image to another
3434
smooth rather than sudden.
3535
The effect is to average out rapid changes in pixel intensity.
36-
A blur is a very common operation we need to perform before other tasks such as
36+
Blurring is a very common operation we need to perform before other tasks such as
3737
[thresholding](07-thresholding.md).
3838
There are several different blurring functions in the `skimage.filters` module,
3939
so we will focus on just one here, the *Gaussian blur*.
@@ -64,10 +64,10 @@ maybe a couple of big features per image.
6464

6565
## Blurring
6666

67-
Blurring is to make something less clear or distinct.
67+
To blur is to make something less clear or distinct.
6868
This could be interpreted quite broadly in the context of image analysis -
6969
anything that reduces or distorts the detail of an image might apply.
70-
Applying a low pass filter, which removes detail occurring at high spatial frequencies,
70+
Applying a low-pass filter, which removes detail occurring at high spatial frequencies,
7171
is perceived as a blurring effect.
7272
A Gaussian blur is a filter that makes use of a Gaussian kernel.
7373

@@ -83,7 +83,7 @@ is a small matrix which is combined with the image using
8383
a mathematical technique: *convolution*.
8484
Different sizes, shapes and contents of kernel produce different effects.
8585
The kernel can be thought of as a little image in itself,
86-
and will favour features of a similar size and shape in the main image.
86+
and will favour features of similar size and shape in the main image.
8787
On convolution with an image, a big, blobby kernel will retain
8888
big, blobby, low spatial frequency features.
8989

@@ -113,7 +113,7 @@ so that the pixel being worked on is always in its centre.
113113
In the example shown above, the kernel is square, with a dimension of seven pixels.
114114

115115
To apply the kernel to the current pixel,
116-
an average of the the colour values of the pixels surrounding it is calculated,
116+
an average of the colour values of the pixels surrounding it is calculated,
117117
weighted by the values in the kernel.
118118
In a Gaussian blur, the pixels nearest the centre of the kernel are
119119
given more weight than those far away from the centre.
@@ -125,7 +125,7 @@ A Gaussian function maps random variables into a normal distribution or "Bell Cu
125125

126126
| *[https://en.wikipedia.org/wiki/Gaussian\_function#/media/File:Normal\_Distribution\_PDF.svg](https://en.wikipedia.org/wiki/Gaussian_function#/media/File:Normal_Distribution_PDF.svg)* |
127127

128-
The shape of the function is described by a mean value μ, and a variance value σ². The mean determines the central point of the bell curve on the x axis, and the variance describes the spread of the curve.
128+
The shape of the function is described by a mean value μ, and a variance value σ². The mean determines the central point of the bell curve on the X axis, and the variance describes the spread of the curve.
129129

130130
In fact, when using Gaussian functions in Gaussian blurring, we use a 2D Gaussian function to account for X and Y dimensions, but the same rules apply. The mean μ is always 0, and represents the middle of the 2D kernel. Increasing values of σ² in either dimension increases the amount of blurring in that dimension.
131131

@@ -156,7 +156,7 @@ while a smaller sigma value results in a more pronounced peak.
156156
The mathematics involved in the Gaussian blur filter are not quite that simple,
157157
but this explanation gives you the basic idea.
158158

159-
To illustrate the blur process,
159+
To illustrate the blurring process,
160160
consider the blue channel colour values from the seven-by-seven region
161161
of the cat image above:
162162

@@ -256,13 +256,12 @@ scikit-image has built-in functions to perform blurring for us, so we do not hav
256256
perform all of these mathematical operations ourselves. Let's work through
257257
an example of blurring an image with the scikit-image Gaussian blur function.
258258

259-
First, import the packages needed for this episode
259+
First, import the packages needed for this episode:
260260

261261
```python
262262
import matplotlib.pyplot as plt
263263
import ipympl
264264
import imageio.v3 as iio
265-
import skimage
266265
import skimage.filters
267266
%matplotlib widget
268267
```
@@ -334,7 +333,7 @@ plt.imshow(blurred)
334333

335334
Somebody said once "an image is worth a thousand words".
336335
What is actually happening to the image pixels when we apply blurring may be
337-
difficult to grasp, let's now visualise the effects of blurring from a different
336+
difficult to grasp. Let's now visualise the effects of blurring from a different
338337
perspective.
339338

340339
Let's use the petri-dish image from previous episodes:
@@ -343,31 +342,31 @@ Let's use the petri-dish image from previous episodes:
343342
Graysacle version of the Petri dish image
344343
](fig/petri-dish.png){alt='Bacteria colony'}
345344

346-
What we want to see here is the pixel intensities from a lateral perspective,
347-
we want to see the profile of intensities .
345+
What we want to see here is the pixel intensities from a lateral perspective:
346+
we want to see the profile of intensities.
348347
For instance, let's look for the intensities of the pixels along the horizontal
349-
at `Y=150`:
348+
line at `Y=150`:
350349

351350
```python
352351
import matplotlib.pyplot as plt
353352
import imageio.v3 as iio
354353
import skimage.color
355354

356-
# read colonies color image and convert to grayscale:
355+
# read colonies color image and convert to grayscale
357356
#
358357
image = iio.imread('data/colonies-01.tif')
359358
image_gray = skimage.color.rgb2gray(image)
360359

361-
# define the pixels we want to view the intensities (profile)
360+
# define the pixels for which we want to view the intensity (profile)
362361
#
363362
xmin, xmax = (0, image_gray.shape[1])
364363
ymin = ymax = 150
365364

366365
# view the image indicating the profile pixels position
367366
#
368-
fig,ax = plt.subplots()
367+
fig, ax = plt.subplots()
369368
ax.imshow(image_gray, cmap='gray')
370-
ax.plot([xmin,xmax], [ymin,ymax], color='red')
369+
ax.plot([xmin, xmax], [ymin, ymax], color='red')
371370
```
372371

373372
![
@@ -379,15 +378,15 @@ alt='Bacteria colony image with selected pixels marker'
379378
The intensity of those pixels we can see with a simple line plot:
380379

381380
```python
382-
# Just rename our "Y" variables for a better reading
381+
# rename our "Y" variables for better reading
383382
#
384383
Y = ymin = ymax
385384

386-
# Select the vector of pixels along "Y"
385+
# select the vector of pixels along "Y"
387386
#
388387
image_gray_pixels_slice = image_gray[Y, :]
389388

390-
# Guarantee the intensity values are in the [0:255] range (unsigned integers)
389+
# guarantee the intensity values are in the [0:255] range (unsigned integers)
391390
#
392391
image_gray_pixels_slice = img_as_ubyte(image_gray_pixels_slice)
393392

@@ -409,15 +408,15 @@ alt='Pixel intensities profile in original image'
409408
And now, how does the same set of pixels look in the corresponding *blurred* image:
410409

411410
```python
412-
# First, let's create a blurred version of (grayscale) image
411+
# first, create a blurred version of (grayscale) image
413412
#
414-
from skimage.filters import gaussian
413+
import skimage.filters
415414

416-
image_blur = gaussian(image_gray, sigma=3)
415+
image_blur = skimage.filters.gaussian(image_gray, sigma=3)
417416

418-
# Like before, plot the pixels profile along "Y"
417+
# like before, plot the pixels profile along "Y"
419418
#
420-
image_blur_pixels_slice = image_blur[Y,:]
419+
image_blur_pixels_slice = image_blur[Y, :]
421420
image_blur_pixels_slice = img_as_ubyte(image_blur_pixels_slice)
422421

423422
fig = plt.figure()
@@ -438,7 +437,7 @@ alt='Pixel intensities profile in blurred image'
438437
And that is why *blurring* is also called *smoothing*.
439438
This is how low-pass filters affect neighbouring pixels.
440439

441-
Now that we saw the effects of blurring an image from
440+
Now that we have seen the effects of blurring an image from
442441
two different perspectives, front and lateral, let's take
443442
yet another look using a 3D visualisation.
444443

@@ -529,11 +528,11 @@ plt.imshow(blurred)
529528
![](fig/rectangle-gaussian-blurred.png){alt='Rectangular kernel blurred image'}
530529

531530
These unequal sigma values produce a kernel that is rectangular instead of square.
532-
The result is an image that is much more blurred in the x direction than the
533-
y direction.
531+
The result is an image that is much more blurred in the X direction than in the
532+
Y direction.
534533
For most use cases, a uniform blurring effect is desirable and
535534
this kind of asymmetric blurring should be avoided.
536-
However, it can be helpful in specific circumstances e.g. when noise is present in
535+
However, it can be helpful in specific circumstances, e.g., when noise is present in
537536
your image in a particular pattern or orientation, such as vertical lines,
538537
or when you want to
539538
[remove uniform noise without blurring edges present in the image in a particular orientation](https://www.researchgate.net/publication/228567435_An_edge_detection_algorithm_based_on_rectangular_Gaussian_kernels_for_machine_vision_applications).
@@ -545,8 +544,8 @@ or when you want to
545544
## Other methods of blurring
546545

547546
The Gaussian blur is a way to apply a low-pass filter in scikit-image.
548-
It is often used to remove Gaussian (i. e., random) noise from the image.
549-
For other kinds of noise, e.g. "salt and pepper", a
547+
It is often used to remove Gaussian (i.e., random) noise in an image.
548+
For other kinds of noise, e.g., "salt and pepper", a
550549
median filter is typically used.
551550
See [the `skimage.filters` documentation](https://scikit-image.org/docs/dev/api/skimage.filters.html#module-skimage.filters)
552551
for a list of available filters.

md5sum.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"episodes/03-skimage-images.md" "2ed4f295d98a05ab0c98550b1dd210f3" "site/built/03-skimage-images.md" "2023-08-16"
99
"episodes/04-drawing.md" "f1c7af067155a6b9c82a932d4cfe65d3" "site/built/04-drawing.md" "2023-07-26"
1010
"episodes/05-creating-histograms.md" "3bf31d32ff27f76d149c26d7c7ab4662" "site/built/05-creating-histograms.md" "2023-07-26"
11-
"episodes/06-blurring.md" "d6ada53a402a2b2e9c39220d7cb67b6e" "site/built/06-blurring.md" "2023-08-16"
11+
"episodes/06-blurring.md" "82f89e07fc0e06647afd59851f37f41a" "site/built/06-blurring.md" "2023-08-27"
1212
"episodes/07-thresholding.md" "23787e4d84f2c46e532e4a2f1267cd55" "site/built/07-thresholding.md" "2023-07-26"
1313
"episodes/08-connected-components.md" "aed2d508ba209ab4c7ed6e3b12be20cd" "site/built/08-connected-components.md" "2023-07-26"
1414
"episodes/09-challenges.md" "e3342f430b45f5480d797b6d54b79bce" "site/built/09-challenges.md" "2023-07-26"

0 commit comments

Comments
 (0)