If we are looking for fundus images of eyes. We are actually need some machanism before we process these images to look for blood vessels. In this article we are looking for color blook vessels detection method in MATLAB. We are going to cover the basic image processing techniques on the fundus images to find out the blood vessels.

fundus images are human eye retina images. In these images the main focus is on the eye retina. This kind of images are widely used in opthalmology to detect and diagnose the eye 👁‍🗨 disease. In this article we are also focusing on fundus images because they provide the details pictures of blood vessels. But these vaggy results in the fundus images may require to be corrected and processed to properly display the blood vessels. This is what we are going to do in today’s article.

With the help of these purified blood vessels, we then later develop the algorithm to properly predict the eye diseases like glaucoma, cataract, etc.

We will use the MATLAB image processing toolbox to do all the image processing tasks. We first convert the images to different color space and then apply some filtration. After we filter the image we are good to do the morphological operations on it.

Steps to do:

  1. Load the fundus image and convert it to grayscale while enhancing its contrast.
  2. Convert the grayscale image to the LAB color space.
  3. Extract the ‘a’ channel from the LAB color space, which represents the red-green color axis.
  4. Threshold the ‘a’ channel to isolate the red blood vessels.
  5. we need to Apply morphological operations for example opening and closing operations to enhance the segmentation of the blood vessels.
  6. Label and measure the segmented blood vessels using regionprops function.
  7. Display the original fundus image with the blood vessels segmented in red color and the measurements of the detected vessels.

There are also other methods to extract the blood vessels in MATLAB but we are demonstrating this novice method just to clarify the basic image processing techniques and power of how this could be utlized in different scenarios.

Here is the code for above mentioned Method

% Load fundus image
fundus = imread('fundus_image.jpg');

% Convert to grayscale and enhance contrast
gray = rgb2gray(fundus);
gray = adapthisteq(gray);

% Convert to LAB color space
lab = rgb2lab(fundus);

% Extract the 'a' channel from the LAB color space
channel_a = lab(:,:,2);

% Threshold the 'a' channel to isolate the red blood vessels
vessels_bw = channel_a > 20;

% Apply morphological operations to enhance the blood vessel segmentation
se = strel('disk', 5);
vessels_bw = imopen(vessels_bw, se);
vessels_bw = imclose(vessels_bw, se);

% Label and measure the blood vessels
vessels_labeled = bwlabel(vessels_bw);
stats = regionprops(vessels_labeled, 'Area', 'BoundingBox', 'MajorAxisLength', 'MinorAxisLength');

% Display the blood vessel segmentation and the measurements
imshow(fundus);
hold on;
for i = 1:numel(stats)
    bb = stats(i).BoundingBox;
    rectangle('Position', bb, 'EdgeColor', 'r', 'LineWidth', 2);
    text(bb(1), bb(2) - 10, sprintf('Major axis: %.2f\nMinor axis: %.2f\nArea: %.2f', ...
        stats(i).MajorAxisLength, stats(i).MinorAxisLength, stats(i).Area), ...
        'Color', 'r', 'FontSize', 10);
end
Code language: JavaScript (javascript)

By Abdul Rehman

My name is Abdul Rehman and I love to do Reasearch in Embedded Systems, Artificial Intelligence, Computer Vision and Engineering related fields. With 10+ years of experience in Research and Development field in Embedded systems I touched lot of technologies including Web development, and Mobile Application development. Now with the help of Social Presence, I like to share my knowledge and to document everything I learned and still learning.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.