title: Sclera blood vessel enhancement and adaptive thresholding
body: <p>I'm trying to enhance the sclera blood vessels after I have done sclera recognition on a color image of a 600x800 image from the UBIRIS eye database. My problem is that after I tried to follow this paper written on this exact problem my results don't match the ones from the paper, enhancement and thresholding don't give the necessary results, so I cannot continue developing my algorithm for sclera matching.</p>
  
  <p>Here is the reference paper I'm trying to use: <a href="https://scholarworks.iupui.edu/bitstream/handle/1805/2096/Thesis_OneDoc_Thomas_FinalETD.pdf" rel="nofollow noreferrer">https://scholarworks.iupui.edu/bitstream/handle/1805/2096/Thesis_OneDoc_Thomas_FinalETD.pdf</a></p>
  
  <p>You're going to find on pages 61 and 62 in the PDF the part which isn't working for me.</p>
  
  <p>Here is the input image I start from:
  <a href="https://i.stack.imgur.com/KPYWO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KPYWO.jpg" alt="input"></a></p>
  
  <p>Here is the segmented image giving back the sclera area:
  <a href="https://i.stack.imgur.com/KIFRy.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KIFRy.jpg" alt="segmented image"></a></p>
  
  <p>Finally, here are the images after blood vessel enhancement and adaptive thresholding. Already blood vessel enhancement doesn't look that good as in the paper, but the adaptive thresholding is totally wrong.</p>
  
  <p><a href="https://i.stack.imgur.com/XYTqg.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XYTqg.jpg" alt="blood vessel enhancement"></a>
  <a href="https://i.stack.imgur.com/DXfD0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DXfD0.jpg" alt="adaptive thresholding"></a></p>
  
  <p>Finally, here is my MATLAB code I tried to write according the paper I previously linked:</p>
  
  <pre><code>    I = rgb2gray(segmentedImage);
  gaborArray = gabor([3,4,5],[0,90,180,270]); %maybe 0,90,180,270 or 0,45,90,135
  [gaborMag, gaborPhase] = imgaborfilt(I,gaborArray);
  f = zeros(size(I,1),size(I,2));
  for i = 1:size(I,1)
      for j = 1:size(I,2)
          for k = 1:12
              f(i,j) = f(i,j) + gaborMag(i,j,k).^2;
          end
          f(i,j) = sqrt(f(i,j));
      end
  end
  
  maxh = max(f(:));
  
  for i = 1:size(I,1)
      for j = 1:size(I,2)
          f(i,j) = f(i,j)/maxh;
      end
  end
  
  TH = 0.33;
  [x,y] = find(f~=0);
  hist = [x,y];
  histH = histogram(hist,255,'Normalization','probability');
  dataH = histH.Values;
  
  thresholdsH = zeros(1,255);
  
  %calculate sum minus constant for each case of T with absolute value and save into array
  for i = 1:255
      currentH = 0;
      for j = 1:i
          currentH = currentH + dataH(j);
      end
      currentH = currentH - TH;
      currentH = abs(currentH);
      thresholdsH(i) = currentH;
  end
  
  [MH, thH] = min(thresholdsH);
  thH = thH / 255;
  
  B = zeros(size(I,1),size(I,2));
  
  for i = 1:size(I,1)
      for j = 1:size(I,2)
          if(f(i,j) &gt; thH)
              B(i,j) = 1;
          else
              B(i,j) = 0;
          end
      end
  end
  
  filteredImage = B;
  </code></pre>
  
  <p>Can anyone help me by finding the problem with this code? First of all, I'm not sure if I'm giving the right parameters to the Gabor filter bank for the 4 even orientations mentioned in the paper. After that normalizing by the maximum value of f is done because otherwise I get a fully white region already after blood vessel enhancement. Where do you reckon the problem is with this code? As far as I understand the paper I did it exactly as it is mentioned there.</p>