1
$\begingroup$

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"];

$\endgroup$
  • $\begingroup$ this can be a start: MorphologicalBinarize[GaussianFilter[img, 0.2], 0.42] // ColorNegate //MaxFilter[#, 1] & $\endgroup$ – Ali Hashmi Jul 2 '17 at 0:01
  • $\begingroup$ Thanks Ali, MaxFilter is great, but I need something sharper $\endgroup$ – JBogoya Jul 4 '17 at 22:05
  • $\begingroup$ MorphologicalBinarize[BrightnessEqualize[img],0.43] // Opening[#, 2] & // DeleteSmallComponents[#, 100] & $\endgroup$ – Ali Hashmi Jul 4 '17 at 22:46
5
$\begingroup$

Almost

HighlightImage[img,bin = MorphologicalBinarize[
   TopHatTransform[GaussianFilter[img, 10], 10], {.01, .02}]]

Mathematica graphics

Fraction about those filaments

N[Total[ImageData[bin], 2]/Times @@ ImageDimensions[bin]]

0.278293

| improve this answer | |
$\endgroup$
  • $\begingroup$ Impressive, thanks a lot $\endgroup$ – JBogoya Jul 4 '17 at 23:15
  • $\begingroup$ Good answer. You could use 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
  • $\begingroup$ @nikie Thanks,that is a good tech.. $\endgroup$ – yode Jul 5 '17 at 8:36
0
$\begingroup$

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 *)

enter image description here

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ I found a little better result using PeronaMaikFilter, LocalAdaptiveBinarize, and DeleteSmallComponents functions $\endgroup$ – JBogoya Jul 4 '17 at 23:16
  • $\begingroup$ @JBogoya Great. Good that worked out for you $\endgroup$ – Ali Hashmi Jul 5 '17 at 8:39
  • $\begingroup$ @JBogoya You can post your own solution as an answer, it is encouraged here. $\endgroup$ – Alexey Popkov Jul 5 '17 at 9:13
  • $\begingroup$ DeleteSmallComponents[ DeleteSmallComponents[LocalAdaptiveBinarize[PeronaMalikFilter[fig, 20], 250], 400] // ColorNegate, 150] // ColorNegate $\endgroup$ – JBogoya Jul 6 '17 at 1:13

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.