0

I am using image_slicer library in python to slice the images in tiff format(target images for image segmentation) to 16 pieces and save to a particular directory.

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')

This is giving following error:

  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)

Shape of the image when loaded as numpy as

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

is (960,960,3)

I have tried the same code for input image paths,it is working as expected. I would like to know how this is happening and how i can avoid this error.Thanks in advance :)

Edit:

Complete error

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)

AVA
  • 173
  • 1
  • 1
  • 6

0 Answers0