Path: news.mathworks.com!newsfeed-00.mathworks.com!news.kjsl.com!newsfeed.stanford.edu!elk.ncren.net!newsflash.concordia.ca!canopus.cc.umanitoba.ca!not-for-mail
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Newsgroups: comp.soft-sys.matlab
Subject: Re: Presence of logical ones around a pixel in a certain direction and distance
Date: Mon, 12 May 2008 17:25:33 +0000 (UTC)
Organization: National Research Council Canada - Conseil national de rechereches Canada
Lines: 37
Message-ID: <g09uid$kfi$1@canopus.cc.umanitoba.ca>
References: <g09hms$lev$1@fred.mathworks.com> <g09ont$rtu$1@fred.mathworks.com>
NNTP-Posting-Host: origin.ibd.nrc.ca
X-Trace: canopus.cc.umanitoba.ca 1210613133 20978 192.70.172.160 (12 May 2008 17:25:33 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Mon, 12 May 2008 17:25:33 +0000 (UTC)
Originator: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Xref: news.mathworks.com comp.soft-sys.matlab:467955


In article <g09ont$rtu$1@fred.mathworks.com>,
helper  <spamless@nospam.com> wrote:
>"Ahmad " <ahmad.humyn@gmail.com> wrote in message 
><g09hms$lev$1@fred.mathworks.com>...

>> Lets say I have binary image. Given a pixel I want to find
>> the number of non-zero values around it in a certain 
>radius,
>> in a certain direction. Lets say I have divided the region
>> around the pixel into 30deg regions (starting from north,
>> 0-30 deg, 30-60deg ... 330-360 deg) upto a distance of x
>> pixels, so that it makes a radial region around the pixel
>> concerned, with spokes at every 30 degrees. I want to find
>> all logical 1 pixels in each region.

>> Looking for an extremely
>> fast way...since I'll be doing this for many pixels

>Until someone comes up with a better way, here's one.


>I can see a few improvements you can make for performance 
>depending on your application.  One might be to use:

>closePts = (p(1)-i).'*(p(2)-j))<=maxDist^2;

If the radius stays the same for each pixel, then for a given
angular sector, the relative offsets of the pixels to be examined
will be the same for each pixel to be examined. One could therefor
pre-calculate the relative offsets for each of the angular sectors,
and then as one stepped through the various pixels, it would become
a straightforward "add absolute index of current pixel to
relative indices and access the array at those locations" and process
the resulting vector.
-- 
  "After all, what problems has intellectualism ever solved?"
                                              -- Robert Gilman