Clear Filters
Clear Filters

neighbourhood of centre point(x,y)

4 views (last 30 days)
wa
wa on 7 Dec 2015
Answered: Walter Roberson on 7 Dec 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 Comment
Adam
Adam on 7 Dec 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.

Sign in to comment.

Answers (2)

Image Analyst
Image Analyst on 7 Dec 2015

Walter Roberson
Walter Roberson on 7 Dec 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 .

Categories

Find more on Visualization in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!