bwhitmiss on a sparse set of locations in MATLAB
Say I have a huge image I
, and a set of pixel locations indexed by pix_locations
(linear indices indexing locations in I
). I would like to run a hit-and-miss operation (i.e. what bwhitmiss does) with a structuring elements SE
only on the locations inde开发者_如何学运维xed by pix_locations
.
I know I can just run bwhitmiss
on the entire image, and then keep the results corresponding to the locations indexed by pix_locations
, but if the image is large, this is a waste and slow (the locations indexed by pix_locations
are sparse).
Are there any ways to run bwhitmiss
selectively on a set of locations on an image?
I suppose you could partition your image, like a K-d tree, than use the bwhitmiss on the non-empty partitions, but I think as bwhitmiss is a simple look-up table operation you wouldn't benefit much from that micro-optimization unless you have really huge and sparse images.
精彩评论