-4

I know that there is a function called nlfilter in matlab. What I'm trying to find is the 4-neighbours of a pixel. Does that means a 2x2 window? Can we do that using nlfilter?

Thanks.

Simplicity
  • 47,404
  • 98
  • 256
  • 385
  • Rather than posting the same (unclear) question multiple times, you should go back and clarify questions for which you have already received answers and tell us why those answers are not sufficient for your requirements. You will receive fewer downvotes and it is more courteous to the people who took the time to try to answer your questions. For instance, you have been told how to find the indices of the 4 neighbors of a matrix component. Why was that insufficient? What do you plan to do with these neighbors once you find them? – beaker Feb 19 '13 at 17:03

1 Answers1

0

I think you might find this easier to comprehend if you think of it in terms of blocks rather than in terms of neighbors. So a 2x2 neighbor is actually just a 2x2 block.

If you are talking about a center pixel relative to a north, south, east, west pixel, then you would want to use a 3x3 block. Unfortunately, that block would also include northeast, northwest, southeast, southwest neighbors.

Here is an example of sliding neighborhood operations in Matlab using nlfilter.

JesseBikman
  • 632
  • 1
  • 5
  • 22