title: how i can implement this algorithm in matlab
body: <p>I am working on an iris recognition system. I want to find the pupil by analyzing connected components in the image using <code>bwconncomp</code>.</p>
  
  <p>The algorithm for pupil detection is as follows:</p>
  
  <ol>
  <li>Connected component labeling works by scanning an image. It groups pixels into components based on pixel connectivity. All pixels in a connected component share similar pixel intensity values and are in some way connected with each other. </li>
  <li>Once all groups of pixels have been determined, each pixel in that group is labeled. The center and the diameter of all groups is determined and the one with the largest diameter is the pupil. </li>
  <li>The parts of the image that lie above and below the iris are occluded by eyelashes and eyelids. These pixels lie above and below the diameter of the pupil. To remove them, set these pixels to be NaNs (Not a Number).</li>
  <li>The min/max iris radius is found to be 90/125. Based on this, 45 pixels to the left and right of the pupil is considered to be the iris region for the proposed algorithm analysis.</li>
  </ol>
  
  <p>My question is: how do I set the space above and below the iris to be NaNs. And how do I obtain the pixels that correspond to the iris?</p>
  
  <p>My code is as follows: </p>
  
  <pre><code>%% Read the file and dilate it
  I = imread('eye.jpg');  %See the comments for the image.
  erodedBW = rgb2gray(I);
  se2 = strel('disk',35); 
  dilatedBW= imdilate(erodedBW ,se2);
  imshow(dilatedBW);
  
  
  %%pupil Detection
  cc2=bwconncomp(dilatedBW);
  labeled = labelmatrix(cc2);
  L = bwlabel(dilatedBW);
  [L, num] = bwlabel(dilatedBW);
  
  %% Find the largest value of L
  count=num;
  largvalue=0;  
  for i=0:count,
      L = bwlabel(dilatedBW);
      if  largvalue&lt;=L
          largvalue=L; 
      end    
  end
  </code></pre>