Outlining certain peri-lesion region


Sorry Herbie, I guess I missunderstood you when you said it was essential to try it as you described it. Again, my bad. I think your code is an elegant way of addressing the problem at hand. I never meant to disrespect you in any way. I apologize if I gave you that impression.



I’ve used the zip-file you send (@Herbie) and tried the macro. It worked, but when I opened this zip-file, there already was some kind of contour, how can I add to other tiff-files? This is something I don’t really understand. Is it via that commercial ImageJ plugin you talked about? Can you maybe explain how this works? If this would work, I would be so happy.

Kind regards,


Good day Kaat,

you wrote:

What I have drawn now is done by hand. I don’t see another option.

I think you mean the lesion contour and you are right, the selection in my zipped image file is meant to be the lesion contour but it wasn’t hand drawn. As you’ve conjectured, it was drawn semi-automatically by the commercial ImageJ-plugin “Horizontal Tracing”.

For my macro, it doesn’t matter, if you draw the contour by hand, using e.g. the “Freehand Line”- or the “Segmented Line”-tool from the ImageJ-toolbar.

As soon as you’ve finished drawing the lesion contour, you can start my macro and it will automatically draw the peri-lesion contour with a distance of 200µm from the lesion contour.





Ok thank you very much for your help. I can’t download the plugin “horizontal tracing”, but it does work if I draw the contour by myself.

Kind regards,



you can’t download it because you need to buy a license first!

If you are interested in a license, please contact me per message off-Forum.




always hard to get that some code requires license and not everything is free :slight_smile:


Come on Emanuele,

how do you make your living?

Already forgotten: Past Saturday was the 200th birthday of Marx.
Work has to be adequately remunerated – no?

Any complaints about having provided gratis help on this Forum in many hundreds of posts?




yes yes I fully agree with you,
but I noticed that a lot of people don’t get easily that sometimes codes are not free.



Is it possible to measure the mean gray value between these 2 lines (200µm outlined area)? So can I take this as a ROI and measure the value only this selected area? Now I tried it with Image>adjust>Threshold and than Analyze>measure and my results are for the whole picture and not only for the selected area.

kind regards,


Hi Kaat,

Have you tried the method I suggested? If you do, you should get a ROI that defines your perilesion area and then you can measure just inside that ROI. You could use the fully manual method I described or the semi-automated method with the macro code I sent. It is laborious but it works. We have used it succesfuly before to do exactly what you need to do (but in fluorescence images).



I tried, but I think I will do it manually. Still, thank you for your help.