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 have a picture,and I want to get a special curve in this picture ,than draw the line in a new picture.inbut I can't do this . Like this: example

The picture is this enter image description here

Anybody have an idea?

share|improve this question
    
This can be done with the method I describe in details [here][1] [1]: mathematica.stackexchange.com/questions/44355/… –  Alexei Boulbitch Apr 15 at 9:25
    
I'd say with this together with the linked post from @AlexeiBoulbitch your question has an answer already –  gpap Apr 15 at 9:39
    
Thank you my friends –  czp Apr 15 at 13:14

2 Answers 2

up vote 13 down vote accepted

A complete solution that gives essentially the result you want is the following:

image = Import["http://i.stack.imgur.com/coBQa.jpg"];

img = ImageResize[image, 300];(*scale down to speed up calculation*)
ImageAdjust[img, {4, 0.2}](*increase contrast*)
ColorReplace[%, White -> Black, 0.05](*"remove" the black text*)
MedianFilter[%, 5](*remove small speckles*)
EdgeDetect[%](*find edges*)
SetAlphaChannel[#, Binarize[#]] &[Colorize[MorphologicalComponents[%], 
ColorRules -> {2 -> Red, _ -> Black}]](*Make the right edge red and the rest transparent*)
ImageCompose[img, %](*compose the original image and the red line*)

To get it to work with the full size image you might need to play with the parameters.

Result:

enter image description here

share|improve this answer
    
+1, I've added the link, I hope you don't mind :) –  Kuba Apr 15 at 10:55
    
Oh,thank you very much!! –  czp Apr 15 at 13:09

This method is mainly based on the CurvatureFlowFilter function, which can preserve the shape of the area according to the gradient of the graylevel.

img = Import["http://i.stack.imgur.com/coBQa.jpg"] // ColorConvert[#, "Grayscale"] &;

The threshold of the first Binarize can be determined by checking the graylevel of some sample points of the interested area:

imgBi = Binarize[img, {0.38, 0.48}]

imgBi

CurvatureFlowFilter is used here to smooth imgBi while keeping the edges relatively unchanged (Note: this function is very time-consuming):

imgSeg = CurvatureFlowFilter[imgBi, 10, 5]

imgSeg

MorphologicalBinarize is useful for excluding small irrelevant areas:

imgMorphBi = MorphologicalBinarize[imgSeg, {.4, .99}]

imgMorphBi

Use any edge extraction method to extract the edges:

imgEdges = GradientFilter[imgMorphBi, 1] // ImageAdjust // Binarize

imgEdges

HighlightImage[img, imgEdges]

highlighted img

share|improve this answer
    
nice to see use of CurvatureFlowFilter. –  s.s.o Apr 15 at 18:34
    
@s.s.o Thanks. It's a very good function, just a bit slow :( –  Silvia Apr 16 at 2:40
    
A nice answer too.Thank you !! –  czp Apr 16 at 8:09
    
@czp Glad to help :) –  Silvia Apr 16 at 10:59

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.