I am trying to extract the outer edge of the attached image. Could you please advice me how to do it?
6
-
$\begingroup$ Have you tried anything? Is it about Mathematica at all? $\endgroup$ – Kuba♦ Feb 3 '19 at 14:04
-
$\begingroup$ Yes I have tried it with Mathematica. The problem is that I don't know how to extract the outer contour only. $\endgroup$ – Florin Feb 3 '19 at 14:23
-
1$\begingroup$ @Florin In the future, it would be really great if you could include what you have done, as a code snippet. This is an interesting problem; what is this shape for? Interfaces between liquids? $\endgroup$ – dearN Feb 3 '19 at 16:02
-
$\begingroup$ @Florin If your question has been answered, please consider marking one of the answers as Accepted! $\endgroup$ – Carl Lange Feb 4 '19 at 8:15
-
$\begingroup$ Hi drN! OK! It is indeed an interface. However I am a real beginner. Not yet able to share codes. I am learning the ABC. $\endgroup$ – Florin Feb 7 '19 at 19:24
|
Show 1 more comments
$\begingroup$
$\endgroup$
1
Assuming the question is about Mathematica...
SelectComponents[
MorphologicalPerimeter@MorphologicalBinarize@i, "Count", -2]
$\begingroup$
$\endgroup$
6
One method to isolate the outer edge in Mathematica is to use the EdgeDetect[]
function.
Note: I hand tuned the program for this image (it will not work for other images).
img = Import["https://i.stack.imgur.com/0wc6Q.jpg"];
EdgeDetect[img, 1, .43] - EdgeDetect[img, 1, .45]
-
1$\begingroup$ Thank you Conor !! I have tried with EdgeDetect but I did not know about using it this way. Thank you very much! $\endgroup$ – Florin Feb 3 '19 at 14:42
-
1$\begingroup$ @ConorCosnett 👋Always nice to see another Irish Mathematica user! $\endgroup$ – Carl Lange Feb 3 '19 at 14:53
-
$\begingroup$ Haha thanks, unfortunately we are a rare breed. (Everyone seems to be wasting their time, reinventing the wheel, in MATLAB and C in these parts.) $\endgroup$ – Conor Cosnett Feb 3 '19 at 15:49
-
$\begingroup$ @ConorCosnett Tell me about it. If you're in Dublin feel free to give me a shout and we can grab a coffee/pint and chat about how much better us Mathematica users are than our peers 😅 $\endgroup$ – Carl Lange Feb 3 '19 at 16:53
-
$\begingroup$ Certainly. I couldn't turn down an opportunity to do that 😂. $\endgroup$ – Conor Cosnett Feb 3 '19 at 17:45
$\begingroup$
$\endgroup$
1
An approach that doesn't need too much tweaking is to use LocalAdaptiveBinarize followed by the selection of the largest component:
img = Import["https://i.stack.imgur.com/0wc6Q.jpg"];
object = ColorNegate@DeleteSmallComponents[LocalAdaptiveBinarize[img, 30]]
MorphologicalPerimeter@SelectComponents[object, "Count", -1]