title: extracting many regions of interests ROIs) from thousand images
body: <p>I have a large set of microscopy images and each image has several hundreds of spots (ROIs). These spots are fixed in space. I want to extract each spot from each image and save into workspace so that I can analyze them further.</p>
  
  <p>I have written a code myself and it working perfectly but its too slow. It takes around 250 sec to completely read out all the spots from every image. </p>
  
  <p>The core of my code looks as following:</p>
  
  <pre><code>for s=1:NumberImages   
    im1=imread(fn(s,1).name);    
    im=im1-medfilt2(im1,[15,15]);    
    for i=1:length(p_g_x)    
      GreenROI(i,s)=double(sum(sum(im(round(p_g_y(i))+(-2:2), round(p_g_x(i))+(-2:2)))));
      RedROI(i,s)=double(sum(sum(im(round(p_r_y(i))+(-2:2), round(p_r_x(i))+(-2:2)))));        
    end
  end
  </code></pre>
  
  <p>As you can see from the code I am extracting 5x5 regions. Length of p_g_x is between 500-700.</p>
  
  <p>Thanks for your input. I used profile viewer to figure out which function exactly is taking more time. It was median filter which is taking a lot of time (~90%).</p>
  
  <p>Any suggestion to fast it up will be greatly appreciated.</p>
  
  <p>thanks</p>
  
  <p>Mahipal</p>