<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Neighbor indexing</title>
	<atom:link href="http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/</link>
	<description>Steve Eddins manages the Image &#38; Geospatial development team at The MathWorks and coauthored Digital Image Processing Using MATLAB. He writes here about image processing concepts, algorithm implementations, and MATLAB.</description>
	<lastBuildDate>Fri, 10 Feb 2012 18:55:59 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Steve</title>
		<link>http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/#comment-22930</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Mon, 29 Mar 2010 19:46:34 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/#comment-22930</guid>
		<description>Ed&#8212;If you&#039;re new to image processing, I&#039;m not sure I would recommend trying to code this from scratch as some sort of neighborhood search. There are a lot of image processing operations already implemented for you in the Image Processing Toolbox: thresholding, edge detection, morphological operations, etc.  Consider getting a book about image processing to familiarize yourself with these operations and how they might be able to help.</description>
		<content:encoded><![CDATA[<p>Ed&mdash;If you&#8217;re new to image processing, I&#8217;m not sure I would recommend trying to code this from scratch as some sort of neighborhood search. There are a lot of image processing operations already implemented for you in the Image Processing Toolbox: thresholding, edge detection, morphological operations, etc.  Consider getting a book about image processing to familiarize yourself with these operations and how they might be able to help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ed</title>
		<link>http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/#comment-22929</link>
		<dc:creator>Ed</dc:creator>
		<pubDate>Mon, 29 Mar 2010 18:33:34 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/#comment-22929</guid>
		<description>First i have to say.. very nice blog.
I need to detect cells in a microscopic image, viable cells are brighter than non viable cells and also they are surrounded by a darker contour, i need to measure the areas of each cell (sometimes i hace 500 cells per picture) i was thinking can i use this technique to find maximum intensity pixels and move around this seeds until a steep change in the intensity value ocurs the contour (my cells are nearly circles) ? i have to say that im new to the image processing field so maybe could you point me in the right direction? would you like to see a sample image maybe?.</description>
		<content:encoded><![CDATA[<p>First i have to say.. very nice blog.<br />
I need to detect cells in a microscopic image, viable cells are brighter than non viable cells and also they are surrounded by a darker contour, i need to measure the areas of each cell (sometimes i hace 500 cells per picture) i was thinking can i use this technique to find maximum intensity pixels and move around this seeds until a steep change in the intensity value ocurs the contour (my cells are nearly circles) ? i have to say that im new to the image processing field so maybe could you point me in the right direction? would you like to see a sample image maybe?.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/#comment-22415</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Fri, 04 Dec 2009 20:57:49 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/#comment-22415</guid>
		<description>Subh&#8212;&lt;tt&gt;id&lt;/tt&gt; needs to be a column vector.

&lt;pre&gt;
id = id(:);
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Subh&mdash;<tt>id</tt> needs to be a column vector.</p>
<pre>
id = id(:);
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Subh</title>
		<link>http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/#comment-22414</link>
		<dc:creator>Subh</dc:creator>
		<pubDate>Fri, 04 Dec 2009 20:47:26 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/#comment-22414</guid>
		<description>Hi Steve, 

I would like to compute all 8 neighbors for each pixel in a 20x40 image matrix except for the borders (1-pixel width). I do the following:

&lt;pre&gt;
  [cols, rows] = meshgrid(2:19, 2:39);
  id = sub2ind(size(img), rows, cols);
  M = size(img,1);
  msk = [-M, -M+1, 1, M+1, M, M-1, -1, -M-1];
  nbrs = bsxfun(@plus, id, msk);
&lt;/pre&gt;

However, I get an error in the bsxfun():
Non-singleton dimensions of the two input arrays must match each other.

What should I be doing in order to get an 8-dimensional vector corresponding to each pixels in the ROI (2:19, 2:39) of my image? Is there a straight forward approach for this?</description>
		<content:encoded><![CDATA[<p>Hi Steve, </p>
<p>I would like to compute all 8 neighbors for each pixel in a 20&#215;40 image matrix except for the borders (1-pixel width). I do the following:</p>
<pre>
  [cols, rows] = meshgrid(2:19, 2:39);
  id = sub2ind(size(img), rows, cols);
  M = size(img,1);
  msk = [-M, -M+1, 1, M+1, M, M-1, -1, -M-1];
  nbrs = bsxfun(@plus, id, msk);
</pre>
<p>However, I get an error in the bsxfun():<br />
Non-singleton dimensions of the two input arrays must match each other.</p>
<p>What should I be doing in order to get an 8-dimensional vector corresponding to each pixels in the ROI (2:19, 2:39) of my image? Is there a straight forward approach for this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Malambo</title>
		<link>http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/#comment-21340</link>
		<dc:creator>Malambo</dc:creator>
		<pubDate>Mon, 22 Dec 2008 10:25:47 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/#comment-21340</guid>
		<description>Steve,
Thank you once more. I am using the flood filling ideas discussed here to implement a region growing segmentation. This blog has really help me to write code that runs fast.
Let re-examine my code and i will get back to you.</description>
		<content:encoded><![CDATA[<p>Steve,<br />
Thank you once more. I am using the flood filling ideas discussed here to implement a region growing segmentation. This blog has really help me to write code that runs fast.<br />
Let re-examine my code and i will get back to you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/#comment-21337</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Mon, 22 Dec 2008 01:06:44 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/#comment-21337</guid>
		<description>Malambo&#8212;I have no idea what your for-loop is doing, but these three lines before the for-loop are getting off to a bad start:

&lt;pre&gt;
seed_pt=1;
neighbor_offsets =[M, M+1, 1, -M+1, -M, -M-1, -1, M-1];
nghood = bsxfun(@plus, seed_pt, neighbor_offsets);
&lt;/pre&gt;

Your initial &lt;tt&gt;seed_pt&lt;/tt&gt; is at the upper-left of the image, on the boundary.  Therefore your computation of its neighborhood using neighbor indexing on the next two lines doesn&#039;t work correctly.</description>
		<content:encoded><![CDATA[<p>Malambo&mdash;I have no idea what your for-loop is doing, but these three lines before the for-loop are getting off to a bad start:</p>
<pre>
seed_pt=1;
neighbor_offsets =[M, M+1, 1, -M+1, -M, -M-1, -1, M-1];
nghood = bsxfun(@plus, seed_pt, neighbor_offsets);
</pre>
<p>Your initial <tt>seed_pt</tt> is at the upper-left of the image, on the boundary.  Therefore your computation of its neighborhood using neighbor indexing on the next two lines doesn&#8217;t work correctly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Malambo</title>
		<link>http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/#comment-21336</link>
		<dc:creator>Malambo</dc:creator>
		<pubDate>Sun, 21 Dec 2008 23:46:23 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/#comment-21336</guid>
		<description>Thanks Steve for your response. 
To avoid padding the image I decided to use this:
&lt;pre&gt;
 if (((xn&gt;=1)&amp;&amp;(yn&gt;=1))&amp;&amp;((xn&lt;=M)&amp;&amp;(yn&lt;=N)))
&lt;/pre&gt;
This restricts the coordinates of the pixels so that only those in the image will be assigned to the local_data matrix. This works well with 4-neighbor but there is one wrong index when I use the 8-neighbor offsets. This is what I really want to know.</description>
		<content:encoded><![CDATA[<p>Thanks Steve for your response.<br />
To avoid padding the image I decided to use this:</p>
<pre>
 if (((xn&gt;=1)&amp;&amp;(yn&gt;=1))&amp;&amp;((xn&lt;=M)&amp;&amp;(yn&lt;=N)))
</pre>
<p>This restricts the coordinates of the pixels so that only those in the image will be assigned to the local_data matrix. This works well with 4-neighbor but there is one wrong index when I use the 8-neighbor offsets. This is what I really want to know.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/#comment-21330</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Fri, 19 Dec 2008 17:57:39 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/#comment-21330</guid>
		<description>Malambo&#8212;Please look closely at the portion of my post where I say that &quot;The neighbor indexing technique DOES NOT WORK FOR PIXELS ON THE BORDERS!&quot;  Also, you might consider using &lt;tt&gt;ind2sub&lt;/tt&gt; to convert from linear indices to subscripts.</description>
		<content:encoded><![CDATA[<p>Malambo&mdash;Please look closely at the portion of my post where I say that &#8220;The neighbor indexing technique DOES NOT WORK FOR PIXELS ON THE BORDERS!&#8221;  Also, you might consider using <tt>ind2sub</tt> to convert from linear indices to subscripts.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Malambo</title>
		<link>http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/#comment-21329</link>
		<dc:creator>Malambo</dc:creator>
		<pubDate>Fri, 19 Dec 2008 16:59:00 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/#comment-21329</guid>
		<description>Steve,
I have tried using the bsxfun to get 8-neighbors for first pixel. One of the values i am getting does not make sense. I am working with an 81 by 83 image and 81 is returned as one of the neighbors for pixel with linear index 1. My code is as shown below:
&lt;pre&gt;
seed_pt=1;
neighbor_offsets =[M, M+1, 1, -M+1, -M, -M-1, -1, M-1];
nghood = bsxfun(@plus, seed_pt, neighbor_offsets);
nghood=nghood&#039;;
nd=size(nghood,1);
cnt=1;
clear local_data
for j=1:nd
       x0=nghood(j); 
       yn=ceil(x0/M); %convert to column coordinate
       xn=rem(x0,M);  %convert to row coordinate
       if xn==0, xn=M;end
       if (((xn&gt;=1)&amp;&amp;(yn&gt;=1))&amp;&amp;((xn&lt;=M)&amp;&amp;(yn&lt;=N)))
         local_data(cnt,:)=reshape(I(xn,yn,:),1,3);
         cnt=cnt+1;
         
       end
end
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Steve,<br />
I have tried using the bsxfun to get 8-neighbors for first pixel. One of the values i am getting does not make sense. I am working with an 81 by 83 image and 81 is returned as one of the neighbors for pixel with linear index 1. My code is as shown below:</p>
<pre>
seed_pt=1;
neighbor_offsets =[M, M+1, 1, -M+1, -M, -M-1, -1, M-1];
nghood = bsxfun(@plus, seed_pt, neighbor_offsets);
nghood=nghood';
nd=size(nghood,1);
cnt=1;
clear local_data
for j=1:nd
       x0=nghood(j);
       yn=ceil(x0/M); %convert to column coordinate
       xn=rem(x0,M);  %convert to row coordinate
       if xn==0, xn=M;end
       if (((xn&gt;=1)&amp;&amp;(yn&gt;=1))&amp;&amp;((xn&lt;=M)&amp;&amp;(yn&lt;=N)))
         local_data(cnt,:)=reshape(I(xn,yn,:),1,3);
         cnt=cnt+1;

       end
end
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/#comment-20405</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Tue, 04 Mar 2008 15:45:34 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/#comment-20405</guid>
		<description>Pat&#8212;&lt;tt&gt;bsxfun&lt;/tt&gt; is in MATLAB.  It was introduced in R2007a.</description>
		<content:encoded><![CDATA[<p>Pat&mdash;<tt>bsxfun</tt> is in MATLAB.  It was introduced in R2007a.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

