从 PIL 图像中提取小区域 python

Extract small regions from a PIL image python

enter image description here

我在 python 中有一个 PIL 图像,如图所示,我想将每个红色小区域分别提取为 jpeg 格式。所以从这个文件中,我期待 file1.jpg、file2.jpg 等

如何获取每个不同文件中的每个子区域?

PIL 在这方面并不真正 excel。我会考虑使用:

  • OpenCV findContours(), 或
  • scikit-image regionprops(),或
  • ImageMagick Connected Components,或
  • Python wand 绑定到 ImageMagick 如上所述