I'm trying to measure what fraction of an image is covered by filaments. I have tried several combinations of image processing functions without any luck. Any help?
img = Import["https://i.stack.imgur.com/Pvh7c.jpg"];
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityI'm trying to measure what fraction of an image is covered by filaments. I have tried several combinations of image processing functions without any luck. Any help?
img = Import["https://i.stack.imgur.com/Pvh7c.jpg"];
Almost
HighlightImage[img,bin = MorphologicalBinarize[
TopHatTransform[GaussianFilter[img, 10], 10], {.01, .02}]]
Fraction about those filaments
N[Total[ImageData[bin], 2]/Times @@ ImageDimensions[bin]]
0.278293
Mean@N@Flatten@ImageData@bin
, then you wouldn't have to divide by the number of pixels
$\endgroup$
– Niki Estner
Jul 5 '17 at 7:44
A HeadStart
by no means it is a complete answer. But one can surely play around with it a bit
img2 = MorphologicalBinarize[GaussianFilter[BrightnessEqualize[img], 2], 0.44] //
Opening[#, 2] & // DeleteSmallComponents[#, 200] &
(* for cropped image i took *)
Length@PixelValuePositions[img2, 1]/(Times@@ImageDimensions[img])
(* ~ 0.20 *)
MorphologicalBinarize[GaussianFilter[img, 0.2], 0.42] // ColorNegate //MaxFilter[#, 1] &
$\endgroup$ – Ali Hashmi Jul 2 '17 at 0:01MorphologicalBinarize[BrightnessEqualize[img],0.43] // Opening[#, 2] & // DeleteSmallComponents[#, 100] &
$\endgroup$ – Ali Hashmi Jul 4 '17 at 22:46