Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to search for the black areas along a line (the horizontal line shown below). Though it is straight in this picture, it could be of irregular shape in other cases. It seems that the ImageTake function can only take rectangle areas. Can anyone tell me how to limit the processing within the line neighborhood area, and mark the black area in the left part?

enter image description here

Update: Several raw images without red marks: enter image description here enter image description here enter image description here

Update2: Other cases with bigger black area somewhere else enter image description here

share|improve this question
    
Please post one (or a few if you can) images without the red label for us to be able to test some approaches –  belisarius Apr 4 '13 at 2:33

1 Answer 1

up vote 17 down vote accepted
i = {"http://i.stack.imgur.com/KjTp9.png", 
     "http://i.stack.imgur.com/AuHP7.png", 
     "http://i.stack.imgur.com/jFkNM.png"};
i1 = Import /@ i;

i2 = ColorNegate /@ Binarize /@ i1;

m = Dilation[#, 10]&/@ (Binarize[#, .8]&/@ ImageAdjust/@ DistanceTransform /@ i2);

Grid@{i1, ColorCombine[ {#1, #1, #2}] & @@@ Transpose[{i1, m}]}

Mathematica graphics

share|improve this answer
    
Oh fantastic! Thank you so much! That's exactly what I wanna achieve –  Tinza123 Apr 4 '13 at 3:14
    
I seriously need to learn functional programming. –  jmlopez Apr 4 '13 at 3:52
    
@jmlopez Well, that make us two –  belisarius Apr 4 '13 at 3:58
    
I've been trying to get a book on this (Power Programming With Mathematica) but I just can't find it. I guess I'll just learn by reading all the clever answers in here. –  jmlopez Apr 4 '13 at 4:15
1  
@jmlopez Get the book for free here mathematica.stackexchange.com/a/22724/193 ... courtesy of a fellow user :) –  belisarius Apr 5 '13 at 2:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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