| 1 |
|
| 2 |
|
| 3 |
import matplotlib.pyplot as plt |
| 4 |
|
| 5 |
import imgviz |
| 6 |
|
| 7 |
|
| 8 |
def centerize(): |
| 9 |
data = imgviz.data.arc2017() |
| 10 |
|
| 11 |
rgb = data["rgb"] |
| 12 |
|
| 13 |
H, W = rgb.shape[:2] |
| 14 |
centerized1 = imgviz.centerize(rgb, shape=(H, H)) |
| 15 |
|
| 16 |
rgb_T = rgb.transpose(1, 0, 2) |
| 17 |
centerized2 = imgviz.centerize(rgb_T, shape=(H, H)) |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
plt.figure(dpi=200) |
| 22 |
|
| 23 |
plt.subplot(131) |
| 24 |
plt.title("original") |
| 25 |
plt.axis("off") |
| 26 |
plt.imshow(rgb) |
| 27 |
|
| 28 |
plt.subplot(132) |
| 29 |
plt.title("centerized1:\n{}".format(centerized1.shape)) |
| 30 |
plt.imshow(centerized1) |
| 31 |
plt.axis("off") |
| 32 |
|
| 33 |
plt.subplot(133) |
| 34 |
plt.title("centerized2:\n{}".format(centerized2.shape)) |
| 35 |
plt.imshow(centerized2) |
| 36 |
plt.axis("off") |
| 37 |
|
| 38 |
return imgviz.io.pyplot_to_numpy() |
| 39 |
|
| 40 |
|
| 41 |
if __name__ == "__main__": |
| 42 |
from base import run_example |
| 43 |
|
| 44 |
run_example(centerize) |