13
$\begingroup$

For glaucoma diagnosis it is common to determine a "cup to disk ratio" which compares the diameter of the optic disk (VDD) and optic cup (VCD). The optical disk is visible as a circular red feature (red channel) and the optic cup shows up as a yellow circle (green channel). How can I calculate the diameter ratio between optic disk and optic cup?

I am able to detect the optic disk with canny edge detection, but I have not found a way to calculate the cup to disk ratio. How might I do that?

enter image description here

$\endgroup$
6
  • $\begingroup$ Can you provide sample images (without labeling) for experimentation? $\endgroup$
    – kirma
    Nov 16, 2015 at 12:53
  • 1
    $\begingroup$ Is your question more about how to automatically find the ellipse pattern in an image? or about fitting an ellipse at a starting point in an image? or more about calculating the size of the ellipse? Please provide a minimal example. $\endgroup$ Nov 16, 2015 at 12:55
  • $\begingroup$ You may also check this answer for ellipse fitting. mathematica.stackexchange.com/questions/25589/… $\endgroup$
    – s.s.o
    Nov 16, 2015 at 13:04
  • $\begingroup$ how about calculating the diameter between optic disk and optic cup? sorry my first question is not complete. i have already detect the optic disk with canny edge detection, but i have not found a way to calculate the diameter of optic disk and optic cup. How might I do that? $\endgroup$ Nov 16, 2015 at 16:44
  • 1
    $\begingroup$ @kirma - Additional info and test images for glaucoma and related eye problems: optic-disc.org $\endgroup$
    – dionys
    Nov 17, 2015 at 12:40

2 Answers 2

27
$\begingroup$

Fitting an ellipse:

i = Import["http://i.stack.imgur.com/W7HJk.jpg"];
lineByCenter[center_, semi_, angle_] := Rotate[Line[{#1 - #2, #1 + #2}], angle, #1]&
                                                                       [center,{0,semi}]
sa    = 1 /. ComponentMeasurements[ Binarize@i, "SemiAxes"]
angle = 1 /. ComponentMeasurements[ Binarize@i, "Orientation"]
bbc   = Mean /@  Last /@ ComponentMeasurements[ Binarize@i, "BoundingBox"] // First
Show[i, Graphics[{Thick, White, Rotate[Circle[bbc, sa], angle, bbc],
                          Blue, lineByCenter[bbc, sa[[1]], angle + Pi/2],
                         Green, lineByCenter[bbc, sa[[2]], angle]}]]

Mathematica graphics

edit

In your previous and now closed question you asked for a yellow "cup" and a red "disk".The problem is that the "cup" barely resembles a same-center ellipse, so you need to define some additional criteria.Look:

i = Import["http://i.stack.imgur.com/W7HJk.jpg"];
s = ChanVeseBinarize[i, "TargetColor" -> {Yellow, Red}];
ImageMultiply[i, ColorNegate@s]

Mathematica graphics

edit2

After some googling I got convinced that the "cup" isn't really constrained to be a co-centered ellipse and the relevant parameters for the diagnosis/prognosis aren't just size measurements, but also the relative position of both components:

enter image description here

$\endgroup$
3
  • $\begingroup$ what this is code for matlab? because im using matlab. can you give example using matlab code $\endgroup$ Nov 18, 2015 at 15:19
  • 9
    $\begingroup$ @indraginanjarA.T This site is specific for Mathematica. You may post Matlab questions at stackoverflow.com $\endgroup$ Nov 18, 2015 at 15:29
  • 6
    $\begingroup$ @indra, it's not our fault that you didn't bother to check that you were asking at an appropriate site. $\endgroup$ Nov 19, 2015 at 1:58
18
$\begingroup$

If you need more precise calculation you may check this answer.

cm = ComponentMeasurements[Binarize@img, "BoundingDiskRadius"]
ct = 1 /. ComponentMeasurements[Binarize@img, "BoundingDiskCenter"];
Show[img, Graphics[{Thick, White, Circle[ct, cm[[1, 2]]]}]]

{1 -> 63.4933}

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.