Skip to content

Virtual (default) pixels value for im_rank? #4593

Answered by jcupitt
jpka- asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @jpka-,

You do this by expanding the input image and cropping the output, for example (in python):

image = image \
    .embed(2, 2, image.width + 5, image.height + 5, extend="background", background=[1,2,3]) \
    .rank(5, 5, 0) \
    .crop(2, 2, image.width, image.height)

It sounds a little inefficient, but libvips is demand-driven, so it'll only compute the pixels it needs for the output.

im_rank is the old vips7 interface, it's vips_rank() now:

https://www.libvips.org/API/current/method.Image.rank.html

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jpka-
Comment options

Answer selected by jpka-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants