0

我在 python 中使用 image_slicer 库将 tiff 格式的图像(用于图像分割的目标图像)切成 16 块并保存到特定目录。

for i,img in enumerate(target_img_path):
  tils=image_slicer.slice(img,16)
  image_slicer.save_tiles(tils, directory='/content/drive/My Drive/tarsplt',prefix='{}'.format(i) ,format='tiff')

这给出了以下错误:

  self.im = Image.core.map_buffer(
--> 207                             self.map, self.size, decoder_name, offset, args
    208                         )
    209                     readonly = 1

TypeError: function takes exactly 6 arguments (5 given)

加载为 numpy 时的图像形状

x3=np.array(load_img(target_img_path[1]))
print(x3.shape)

是 (960,960,3)

我已经为输入图像路径尝试了相同的代码,它按预期工作。我想知道这是怎么发生的以及如何避免这个错误。在此先感谢 :)

编辑:

完全错误

TypeError                                 Traceback (most recent call last)

<ipython-input-51-f787e5bb2b19> in <module>()
      1 for i,img in enumerate(target_img_path):
----> 2   tils=image_slicer.slice(img,16,save=False)
      3   image_slicer.save_tiles(tils, directory='/content/drive/My Drive/tarsplt',prefix='{}'.format(i) ,format='tiff')

3 frames

/usr/local/lib/python3.6/dist-packages/image_slicer/main.py in slice(filename, number_tiles, col, row, save, DecompressionBombWarning)
    188         for pos_x in range(0, im_w - columns, tile_w):  # as above.
    189             area = (pos_x, pos_y, pos_x + tile_w, pos_y + tile_h)
--> 190             image = im.crop(area)
    191             position = (int(floor(pos_x / tile_w)) + 1, int(floor(pos_y / tile_h)) + 1)
    192             coords = (pos_x, pos_y)

/usr/local/lib/python3.6/dist-packages/PIL/Image.py in crop(self, box)
   1103         im.palette = ImagePalette.ImagePalette(mode, im.im.getpalette(mode, mode))
   1104 
-> 1105         return im
   1106 
   1107     def copy(self):

/usr/local/lib/python3.6/dist-packages/PIL/TiffImagePlugin.py in load(self)
   1056         if self.tile and self.use_load_libtiff:
   1057             return self._load_libtiff()
-> 1058         return super().load()
   1059 
   1060     def load_end(self):

/usr/local/lib/python3.6/dist-packages/PIL/ImageFile.py in load(self)
    205                             )
    206                         self.im = Image.core.map_buffer(
--> 207                             self.map, self.size, decoder_name, offset, args
    208                         )
    209                     readonly = 1

TypeError: function takes exactly 6 arguments (5 given)

4

0 回答 0