I’m trying to take an image that consists of several noisy ellipses and use ListContourPlot to generate a contour of the image. However, I’m just getting a single dense line. If I binarize the image I get the correct result, but I lose the detail needed for the contour to be good. However, if I use Posterization with a value of two, it also doesn’t work. What is Binarize doing that Posterize isn’t, and why does ListContourPlot work with one but not the other?
Sidenotes: I’ve looked at the image data and the background of the image even before Posterization is mostly true black.
Contours also work with DistanceTransform.
Code:
FN = DialogInput[{filename = temp}, Column[{"Browse for your file:", InputField[Dynamic[filename], String, FieldHint -> "Enter your file name"], FileNameSetter[Dynamic[filename], "Open", Method -> "Preemptive"], DefaultButton[DialogReturn[filename]]}]]; img = Import[FN]; img = ColorConvert[img, "Grayscale"]; (*img = ChanVeseBinarize[img]*) img = ImageEffect[img, {"Posterization", 2}] pic2 = ListContourPlot[ImageData[img, DataReversed -> True], ContourShading -> None, Frame -> False, ContourStyle -> Yellow]; Show[img, pic2]
Image In:
Image Output: