File: plot_scientific.py

package info (click to toggle)
skimage 0.26.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 32,720 kB
  • sloc: python: 61,600; cpp: 2,592; ansic: 1,591; xml: 1,342; javascript: 1,267; makefile: 135; sh: 16
file content (64 lines) | stat: -rw-r--r-- 1,511 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
=================
Scientific images
=================

The title of each image indicates the name of the function.

"""

import matplotlib.pyplot as plt
import matplotlib
import numpy as np
import skimage as ski

matplotlib.rcParams['font.size'] = 18

images = (
    'hubble_deep_field',
    'immunohistochemistry',
    'lily',
    'microaneurysms',
    'moon',
    'retina',
    'shepp_logan_phantom',
    'skin',
    'cell',
    'human_mitosis',
)


for name in images:
    caller = getattr(ski.data, name)
    image = caller()
    plt.figure()
    plt.title(name)
    if image.ndim == 2:
        plt.imshow(image, cmap=plt.cm.gray)
    else:
        plt.imshow(image)

plt.show()


############################################################################
# Thumbnail image for the gallery

# sphinx_gallery_thumbnail_number = -1

fig, axs = plt.subplots(nrows=3, ncols=3)
for ax in axs.flat:
    ax.axis("off")
axs[0, 0].imshow(ski.data.hubble_deep_field())
axs[0, 1].imshow(ski.data.immunohistochemistry())
axs[0, 2].imshow(ski.data.lily())
axs[1, 0].imshow(ski.data.microaneurysms())
axs[1, 1].imshow(ski.data.moon(), cmap=plt.cm.gray)
axs[1, 2].imshow(ski.data.retina())
axs[2, 0].imshow(ski.data.shepp_logan_phantom(), cmap=plt.cm.gray)
axs[2, 1].imshow(ski.data.skin())
further_img = np.full((300, 300), 255)
for xpos in [100, 150, 200]:
    further_img[150 - 10 : 150 + 10, xpos - 10 : xpos + 10] = 0
axs[2, 2].imshow(further_img, cmap=plt.cm.gray)
plt.subplots_adjust(wspace=-0.3, hspace=0.1)