Image processing: draw lines or polygons on object

I am looking for image processing functions to draw lines or polygons on selected objects (please see attached image. Source:

http://www.wolfram.com/solutions/industry/image-processing/information-kit/content/ImageProcessingFlyer.pdf

I tried but could not find a right function. I really appreciate inputs from somebody who knows it.

Thank you very much.

Hi,

this is only the main idea. The process is not optimised. I don’t have your image, so I take an example image:

![img = ExampleData\[{"TestImage", "JellyBeans2"}\];][1]

Now we can use MorphologicalPerimeter to identify edges and then ImageCompose to combine the images.

ImageCompose[img, {MorphologicalPerimeter[img, 0.6], 0.4}]

If you want black lines it looks like this:

ImageCompose[img, {ColorNegate[MorphologicalPerimeter[img, 0.6]], 0.3}]

You can also use ImageMultiply

ImageMultiply[img, ColorNegate[MorphologicalPerimeter[img, 0.6]]]

ImageAdd can also work:

ImageAdd[img, MorphologicalPerimeter[img, 0.6]]

You might also want to either Binarize or remove the Background first.

ImageCompose[img, {MorphologicalPerimeter[RemoveBackground[img, White], 0.2], 0.4}]

It’s playing a bit around with parameters and related functions.
In fact, there are more ways of achieving the same effect. I hope that the ones I pointed out will be useful for you.

Cheers,

Marco