Ndimage or skimage functions for returning pixel neighborhoods

断了今生、忘了曾经 提交于 2019-12-08 04:52:50

问题


Does anyone know of any efficient ways of computing a pixel's neighborhood and returning it in array form based on an input image and pixel coordinates? I would like to compute a number of pixel level features, such as integrated intensity and the Haralick features, based on these neighborhoods.


回答1:


I can think of at least two approaches:

  1. Construct slice objects corresponding to your coordinates, then index into the array with those slices individually.
  2. Construct index arrays based on your coordinates, and use fancy indexing to extract the windows. This requires more memory, but is faster if you want to grab all windows with one go. For an example of something similar, have a look at this example: http://stefanvdwalt.bitbucket.org/assp2013/numpy/#25


来源:https://stackoverflow.com/questions/18793406/ndimage-or-skimage-functions-for-returning-pixel-neighborhoods

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!