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

  • $\begingroup$ Can you provide sample images (without labeling) for experimentation? $\endgroup$ – kirma Nov 16 '15 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$ – Thies Heidecke Nov 16 '15 at 12:55
  • $\begingroup$ You may also check this answer for ellipse fitting. mathematica.stackexchange.com/questions/25589/… $\endgroup$ – s.s.o Nov 16 '15 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$ – indra ginanjar A.T Nov 16 '15 at 16:44
  • 1
    $\begingroup$ @kirma - Additional info and test images for glaucoma and related eye problems: optic-disc.org $\endgroup$ – dionys Nov 17 '15 at 12:40

Fitting an ellipse:

i = Import["http://i.stack.imgur.com/W7HJk.jpg"];
lineByCenter[center_, semi_, angle_] := Rotate[Line[{#1 - #2, #1 + #2}], angle, #1]&
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


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


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

  • $\begingroup$ what this is code for matlab? because im using matlab. can you give example using matlab code $\endgroup$ – indra ginanjar A.T Nov 18 '15 at 15:19
  • 9
    $\begingroup$ @indraginanjarA.T This site is specific for Mathematica. You may post Matlab questions at stackoverflow.com $\endgroup$ – Dr. belisarius Nov 18 '15 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$ – J. M.'s ennui Nov 19 '15 at 1:58

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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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