ldt-

scipy 图像处理(scipy.misc、scipy.ndimage)、matplotlib 图像处理

from scipy.misc import 
imread / imsave / imshow 
imresize / imrotate / imfilter

1. scipy.misc 下的图像处理

from scipy.misc import imread, imresize, imsave
I = imread(\'./cat.jpg\')
I_tinted = I * (1, .95, .9)
I_tinted = imresize(I_tinted, (300, 300))
                # print(I_tinted.shape)
imsave(\'./figs/cat_tinted.jpg\', I_tinted)
  • imread():返回的是 numpy.ndarray 也即 numpy 下的多维数组对象;
  • I_tinted = imresize(I_tinted, (300, 300)),经过 imresize 操作得到的 I_tinted 仍然是 3 维的彩色信息(I_tinted.shape ⇒ (300, 300, 3));

若想显示图像,则一般使用 matplotlib 下的 相关函数:

import matplotlib.pyplot as plt
plt.subplot(1, 2, 1)
plt.imshow(I)
plt.subplot(1, 2, 2)
plt.imshow(I_tinted)
plt.axis(\'off\')
plt.show()

2. scipy.ndimage

  • from scipy.ndimage import uniform_filter:均值滤波; 
    • 关于 scipy 填充 mode 参数的选择的讨论

3. matplotlib 下的图像处理

  • 改变颜色空间:matplotlib.colors.rgb_to_hsv: 
    • 注意接收的参数必须在 [0, 1] 区间内;
    • 返回值也是 [0, 1] 区间内;

分类:

技术点:

相关文章:

  • 2021-07-26
  • 2021-11-28
  • 2022-01-28
  • 2021-04-30
  • 2021-11-25
  • 2021-12-29
  • 2021-10-03
  • 2021-07-04
猜你喜欢
  • 2021-11-11
  • 2021-05-02
  • 2021-10-05
  • 2021-05-19
  • 2021-08-29
  • 2021-12-02
  • 2022-12-23
相关资源
相似解决方案