I am trying to split this input image into three/four equal-sized pieces horizontally but I am not getting the desired output. I don't know what I am doing wrong. Here is the code which I wrote to split it:
import os.path
import numpy as np
from PIL import image
input_1 = "/home/task-1/split_operation/111.jpg"
outputPath = "/home/task-1/split_operation/"
im = Image.open(input_1)
x_width, y_height = im.size
split = np.int(x_width / 3)
outputFileFormat = "{0}-{1}.jpg"
baseName = "cropped_1"
for i in range(0, x_width, split):
x = split + i
box = (x, 0, x + split, y_height)
a = im.crop(box)
a.load()
outputName = os.path.join(outputPath, outputFileFormat.format(baseName, i + 1))
a.save(outputName, "JPEG")
The input image:
The output images I currently get:
As you can see last two images are black. I don't know why I am getting a black image.
