-
Notifications
You must be signed in to change notification settings - Fork 56
Closed
Labels
Description
I am trying to slide the image horizontally and vertically with certain pixels. For now, I am doing this by cropping the row or column of the original image and joining them together but doing so violates the sequential access mode. Numpy has an inbuilt function np.roll(image, shift_value, axis) and I am curious if there is any function like np.roll in pyvips.? Or is there any way around to accomplish the same task without violating sequential mode?
shifting_value = 200
img = pyvips.Image.new_from_file("A.jpg", access='random')
w, h = img.width, img.height
# sliding image upwards
lower_portion = img.crop(0, shifting_value, w, h - shifting_value)
upper_portion = img.crop(0, 0, w, shifting_value)
lower_portion = lower_portion.join(upper_portion, 'vertical')
#lower_portion.write_to_file("shifted_up.jpg")
#sliding image downwards
lower_portion = img.crop(0, h - shifting_value, w, shifting_value)
upper_portion = img.crop(0, 0, w, h - shifting_value)
lower_portion = lower_portion.join(upper_portion, 'vertical')
lower_portion.write_to_file("shifted_down.jpg")
Reactions are currently unavailable