title: Matlab: Avoid for-loops for bayer-pattern demosaicing
body: <p>I implemented a bayer demosaicing and thats works so far, but it is quite slow. I am novice to matlab and figured already that for-loops are usually a bad way of doing things.</p>
  
  <p>That is my algorithim in pseudo-code, can anyone give me a hint how to matlabize it a bit more?</p>
  
  <pre><code>pic = zero(width, height, 3)
  for i=1:Width
     for j=1:Height
         if isbluevalue(i, j)
            pic(i,j) = getOtherTwoValues(...)
         if isredvalue(i,j)
            //do accordingly
         if isgreenvalue(i,j)
            //do accordingly
   end
  end
  </code></pre>
  
  <p>Is there a way to get rid of the for-loops?</p>