<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173142</link>
    <title>MATLAB Central Newsreader - imfill(image,'holes',sizeHoles)</title>
    <description>Feed for thread: imfill(image,'holes',sizeHoles)</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Thu, 24 Jul 2008 03:01:02 -0400</pubDate>
      <title>imfill(image,'holes',sizeHoles)</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173142#445041</link>
      <author>Mario </author>
      <description>Hi.&lt;br&gt;
Is there any way to select the holes I want to fill?&lt;br&gt;
I'd like to fill just the holes smaller than a certain size&lt;br&gt;
(say 100 pixels), so I was wondering if there is a way to do&lt;br&gt;
that. Possibly without using imdilate and imerode (because&lt;br&gt;
using these commands it can happen that i fill holes that i&lt;br&gt;
want to keep).&lt;br&gt;
Thanks for your help!&lt;br&gt;
&lt;br&gt;
M.</description>
    </item>
    <item>
      <pubDate>Thu, 24 Jul 2008 12:29:07 -0400</pubDate>
      <title>Re: imfill(image,'holes',sizeHoles)</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173142#445146</link>
      <author>Steve Eddins</author>
      <description>Mario wrote:&lt;br&gt;
&amp;gt; Hi.&lt;br&gt;
&amp;gt; Is there any way to select the holes I want to fill?&lt;br&gt;
&amp;gt; I'd like to fill just the holes smaller than a certain size&lt;br&gt;
&amp;gt; (say 100 pixels), so I was wondering if there is a way to do&lt;br&gt;
&amp;gt; that. Possibly without using imdilate and imerode (because&lt;br&gt;
&amp;gt; using these commands it can happen that i fill holes that i&lt;br&gt;
&amp;gt; want to keep).&lt;br&gt;
&amp;gt; Thanks for your help!&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; M.&lt;br&gt;
&lt;br&gt;
Interesting question.&lt;br&gt;
&lt;br&gt;
Try something like this:&lt;br&gt;
&lt;br&gt;
1. Fill all holes using imfill&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;filled = imfill(original, 'holes');&lt;br&gt;
&lt;br&gt;
2. Identify filled pixels using logical operators:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;holes = filled &amp; ~original;&lt;br&gt;
&lt;br&gt;
3. Use bwareaopen to eliminate connected components in the holes image &lt;br&gt;
smaller than your threshold.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;bigholes = bwareaopen(holes, 100);&lt;br&gt;
&lt;br&gt;
4. Use logical operators to identify small holes:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;smallholes = holes &amp; ~bigholes;&lt;br&gt;
&lt;br&gt;
5. Use logical operator to fill in identified small holes:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;new = original | smallholes;&lt;br&gt;
&lt;br&gt;
---&lt;br&gt;
Steve Eddins&lt;br&gt;
&lt;a href=&quot;http://blogs.mathworks.com/steve/&quot;&gt;http://blogs.mathworks.com/steve/&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Sat, 30 Aug 2008 11:58:02 -0400</pubDate>
      <title>Re: imfill(image,'holes',sizeHoles)</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173142#598060</link>
      <author>Pete </author>
      <description>Hi,&lt;br&gt;
&lt;br&gt;
I did this using,&lt;br&gt;
&lt;br&gt;
new = ~bwareaopen(~original, 100);&lt;br&gt;
&lt;br&gt;
The results are not quite the same - in contrast to imfill, this method will also &lt;br&gt;
fill in holes occurring at the image boundary, which may or may not be &lt;br&gt;
desirable.</description>
    </item>
  </channel>
</rss>

