Parallel function like numpy.roll to slide image in sequential mode
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")
Hello, yes, wrap does this:
b = a.wrap(x=50, y=50)
Wraps the origin around to (50, 50).
It won't work in sequential mode, sorry. You'd need to copy to memory beforehand:
b = a.copy_memory().wrap(x=50, y=50)
Thank you very much it helped a lot.