0% found this document useful (0 votes)
116 views1 page

Segmentation Example Matlab

The document describes a computer vision algorithm for segmenting blood vessels in retinal images. It reads in an image, converts it to grayscale, enhances contrast, excludes background pixels, thresholds to create a binary image, and removes small pixels to isolate the blood vessels, which are overlaid on the original color image.

Uploaded by

blzz2net
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
116 views1 page

Segmentation Example Matlab

The document describes a computer vision algorithm for segmenting blood vessels in retinal images. It reads in an image, converts it to grayscale, enhances contrast, excludes background pixels, thresholds to create a binary image, and removes small pixels to isolate the blood vessels, which are overlaid on the original color image.

Uploaded by

blzz2net
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

%% Computer Assisted Retinal Blood Vessel Segmentation Algorithm

% Developed and Copyrighted by Tyler L. Coye (2015)


%
% Read Image
I = imread('/Users/Bless/Desktop/untitled folder/mini project.jpg');

% Resize image for easier computation


B = imresize(I, [584 565]);

% Read image
im = im2double(B);

% Convert RGB to Gray via PCA


lab = rgb2lab(im);
f = 0;
wlab = reshape(bsxfun(@times,cat(3,1-f,f/2,f/2),lab),[],3);
[C,S] = pca(wlab);
S = reshape(S,size(lab));
S = S(:,:,1);
gray = (S-min(S(:)))./(max(S(:))-min(S(:)));

%% Contrast Enhancment of gray image using CLAHE


J = adapthisteq(gray,'numTiles',[8 8],'nBins',128);

%% Background Exclusion
% Apply Average Filter

h = fspecial('average', [9 9]);
JF = imfilter(J, h);
figure, imshow(JF)

% Take the difference between the gray image and Average Filter
Z = imsubtract(JF, J);
figure, imshow(Z)

%% Threshold using the IsoData Method


level=isodata(Z); % this is our threshold level

%% Convert to Binary
BW = im2bw(Z, level-.008);

%% Remove small pixels


BW2 = bwareaopen(BW, 100);

%% Overlay
BW2 = imcomplement(BW2);
out = imoverlay(B, BW2, [0 0 0]);
figure, imshow(out)

You might also like