neighbourhood of centre point(x,y)

1 vue (au cours des 30 derniers jours)
wa
wa le 7 Déc 2015
I have a point (x,y)(centre of image) and the radius r is 12, so I want to find all the points within r of 12 to the point (x,y). I know spatial filtering and have applied nfilter for centre pixel
  1 commentaire
Adam
Adam le 7 Déc 2015
Isn't it just simply all points within a radius 12 circle? Which is just a Pythagoras calculation on every point vs the centre.
Or to be more efficient, on every point inside a 25-by-25 square centred on your image centre since no point outside that can be within a radius of 12.

Connectez-vous pour commenter.

Réponses (2)

Image Analyst
Image Analyst le 7 Déc 2015

Walter Roberson
Walter Roberson le 7 Déc 2015
One time, You start with a 25 x 25 array and compute all the points within r = 12 of the center point. This will allow you to construct a list of (signed) relative rows and columns of the points that are within range. You can then hard-code that list.
Then once you know the actual image size, before you loop, you multiply the (signed) relative column offsets by the number of rows in the image, and add the (signed) relative row offsets. The result will give you a list of relative linear indices.
Now as you go through the matrix, you can add the list of relative linear indices to your current linear index, in order to calculate the linear indices of the points that are within range; you can then extract their values and do whatever with them. Just watch out for the borders -- these relative calculations would only be good from row 12 to row end-11 and column 12 to column end-11 .

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by