Blood vessel identification from an OCT image

32 Ansichten (letzte 30 Tage)
shal_sn
shal_sn am 10 Jun. 2025 um 7:13
Kommentiert: Mathieu NOE am 16 Jun. 2025 um 8:15
Hello,
I have an image that I want to identify blood vessels in (marked with arrows)
Does anyone have an idea how to do this? Basically, I need the borders of the blood vessels.
The original image:

Antworten (1)

Mathieu NOE
Mathieu NOE am 10 Jun. 2025 um 10:07
let's try something with edge approach : nice but how do you then isolate the black thicker line as the identified blood vessel ?
% Read the input image
image = imread('image.jpg');
grayImage = rgb2gray(image); % Convert to grayscale if it's a color image
% Enhance contrast using adaptive histogram equalization
enhancedImage = adapthisteq(grayImage);
% Apply a median filter to reduce noise
filteredImage = medfilt2(enhancedImage, [3 3]);
% Use edge detection to highlight blood vessels
edges = edge(filteredImage, 'log');
% Perform morphological operations to refine the segmentation
se = strel('disk', 4); % Structuring element
dilatedEdges = imdilate(edges, se); % Dilate edges
cleanedEdges = imerode(dilatedEdges, se); % Erode to clean up
% Display the results
% figure, imshow(enhancedImage), title('Enhanced Image');
% figure, imshow(filteredImage), title('Filtered Image');
figure, imshow(edges), title('Edge Detection');
figure, imshow(cleanedEdges), title('Final Segmentation');
  2 Kommentare
Mathieu NOE
Mathieu NOE am 10 Jun. 2025 um 10:10
then this my suggestion, not anything fancy based on image processing tbx
as per my understanding the blood vessel is within the two magenta curves
% Read the input image
A = imread('image.jpg');
A = rgb2gray(A); % Convert to grayscale if it's a color image
A = double(A);
A = flipud(A); % to have image displayed with correct y direction
[y,x] = find(A>50);
[xtop,ytop,xbottom,ybottom,] = top_bottom_boundary(x,y);
figure(1)
imagesc(A);
colorbar('vert');
set(gca,'YDir','normal');
colormap('gray');
hold on
plot(xtop, ytop, '--r', xbottom, ybottom, '--g','linewidth',2)
% first find the blood vessel center line ("valey")
for k = 1:numel(xtop)
s = A(:,k);
[minS,ind] = min(s(ybottom(k):ytop(k)));
xline(k) = k;
yline(k) = ind+ybottom(k);
zline(k) = minS;
end
% smooth zline profile before moving on
zline = smoothdata(zline,'gaussian',50);
% smooth yline profile before moving on
yline = round(smoothdata(yline,'gaussian',50))'; % nb : must be rounded because after used as an index
% now find top and bottom envelope of blood vessel
for k = 1:numel(xtop)
s = A(:,k);
% find upper line with threshold factor with zline
thres = 1.25;
[valU,indU] = min(abs(s(yline(k):ytop(k))-thres*zline(k)));
yu(k) = yline(k)+indU;
% find lower line with threshold factor with zline
thres = 1.5;
[valL,indL] = min(abs(s(yline(k):-1:ybottom(k))-thres*zline(k)));
yl(k) = yline(k)-indL;
end
%smooth it a bit
N = 50;
yu = smoothdata(yu,'gaussian',N);
yl = smoothdata(yl,'gaussian',N);
% remove incorrect start and stop because of YTicks in image
n = 16;
yline(1:n) = NaN;
yline(end-n:end) = NaN;
yu(1:n) = NaN;
yu(end-n:end) = NaN;
yl(1:n) = NaN;
yl(end-n:end) = NaN;
% final plot
plot(xline,yline,'--c')
plot(xline,yu,'m')
plot(xline,yl,'m')
legend('top boundary','bottom boundary','bv center line','bv top','bv bottom');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [x3,y3,x4,y4] = top_bottom_boundary(x,y)
% based on FEX : https://fr.mathworks.com/matlabcentral/answers/299796-tight-boundary-around-a-set-of-points
%split data into classes and find max/min for each class
class_label = unique(x);
upper_boundary = zeros(size(class_label));
lower_boundary = zeros(size(class_label));
for idx = 1:numel(class_label)
class = y(x == class_label(idx));
upper_boundary(idx) = max(class);
lower_boundary(idx) = min(class);
end
% left_boundary = y(x == class_label(1));
% right_boundary = y(x == class_label(end));
%
% % left_boundary
% x1 = class_label(1)*ones(size(left_boundary));
% y1 = left_boundary;
%
% % right_boundary
% x2 = class_label(end)*ones(size(right_boundary));
% y2 = right_boundary;
% top boundary
x3 = class_label;
y3 = upper_boundary;
% bottom boundary
x4 = class_label;
y4 = lower_boundary;
end
Mathieu NOE
Mathieu NOE am 16 Jun. 2025 um 8:15
hello
problem solved ?

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by