Skip to content

Parallel function like numpy.roll to slide image in sequential mode #116

@akaprasanga

Description

@akaprasanga

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions