如何使用matlab从视网膜图像检测视杯和光盘?我想找出视神经边缘matlab中的图像处理(分割)
我曾尝试下面的代码
RGB = imread('img/A(4).jpg');
G = DialateBloodVessel(RGB);
[BW,H] = RGBThresh(G,220,60);
H = H(:,:,3);
I = edge(H,'Roberts',0.1);
imshowpair(I,G);
%%%%%%%%%% DialateBloodVessel(RGB) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [ RemovedBV ] = DialateBloodVessel(RGB)
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
IM = RGB;
SE = strel('disk',10);
IM2 = imdilate(IM,SE);
%SE2 = strel('disk',10);
RemovedBV = imerode(IM2,SE);
end
%%%%%%%%%% RGBThresh(RGB,Ch1,Ch3) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [BW,maskedRGBImage] = RGBThresh(RGB,Ch1,Ch3)
I = RGB;
% Define thresholds for channel 1 based on histogram settings
channel1Min = Ch1;
channel1Max = 255.000;
% Define thresholds for channel 2 based on histogram settings
channel2Min = 0.000;
channel2Max = 185.000;
% Define thresholds for channel 3 based on histogram settings
channel3Min = Ch3;
channel3Max = 255.000;
% Create mask based on chosen histogram thresholds
sliderBW = (I(:,:,1) >= channel1Min) & (I(:,:,1) <= channel1Max) & ...
(I(:,:,2) >= channel2Min) & (I(:,:,2) <= channel2Max) & ...
(I(:,:,3) >= channel3Min) & (I(:,:,3) <= channel3Max);
BW = sliderBW;
% Initialize output masked image based on input image.
maskedRGBImage = RGB;
% Set background pixels where BW is false to zero.
maskedRGBImage(repmat(~BW,[1 1 3])) = 0;
end
我得到下面的输出(视杯和视盘之间的距离)的测量,但我需要完美的圆在任何图像:
我试图霍夫变换获取了圈,也试过颜色阈值,但两者时间我得到不想要的输出。 –
我已更新代码,只需看一下 –
如何在此处上传文件? –