Extracting the bounding area of connected components #4699
Replies: 2 comments 6 replies
-
|
Hello @4lch,
You can get the bounding box by making an XY image, then finding an indexed histogram with min and then max. But I think the optimisation in https://www.libvips.org/API/current/ctor.Image.xyz.html There's also https://www.libvips.org/API/current/method.Image.fill_nearest.html It infills zero pixels with the nearest non-zero pixel, it might do what you want. There are some edge cases where it fails, unfortunately, but it works OK for small voids. I ought to try to fix it :(
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
-
Hello !
I am currently implementing the Fast Digital Image Inpainting paper to perform high-performance image inpainting with Vips. The basic premise is pretty simple, initialize areas to be inpainted with the average value of the image, then run multiple convolutions with a diffusion kernel to bleed values outside of the areas to inpaint inwards. This works remarkably well for small areas to inpaint, even if it has a smoothing effect. The performance of my implementation that runs the convolutions over the entire image is already 2 orders of magnitude faster than OpenCV's Telea !!
Using NetVips:
I am now trying to see whether this could be optimized further, by limiting the convolutions to areas surrounding each spot to inpaint. The connected-components-labelled mask with false colors looks like this :
My question is then, how to properly get the bounding box around each connected element ? I have seen
vips_hist_find_indexed()mentioned for this but couldn't seem to wrap my head around actually using it for bounding box extraction of connected components ? I am not sure that an approach where the convolution would run on smaller portions of images would actually be faster, but this feels worth trying if it can squeeze extra performance :)Thanks a lot in advance !
Beta Was this translation helpful? Give feedback.
All reactions