0

I have a binary image of separated spots.

Source binary image of sports

Is there any ImageJ plugin that could construct convex hull of all spots?

Or could you recommend another program, not ImageJ, that can do this?

user2518618
  • 1,360
  • 13
  • 32
Ivan Z
  • 1,517
  • 1
  • 16
  • 25

3 Answers3

1

With OpenCV you can use findContours() and then convexHull()

You can see a complete example here: https://docs.opencv.org/2.4/doc/tutorials/imgproc/shapedescriptors/hull/hull.html

OpenCV is a library, which means that you have to code the program yourself. It has bindings for Java, python and many other languages. You can easily find the same example in other languages:

Convex Hull on Java Android Opencv 2.3

user2518618
  • 1,360
  • 13
  • 32
1

Provided you have an 8-bit (binary) image in ImageJ, you can run the following Groovy script from the script editor to get the convex hull as current selection:

#@ ImagePlus imp

import ij.gui.PolygonRoi
import ij.gui.Roi
import ij.plugin.filter.ThresholdToSelection
import ij.process.ImageProcessor

imp.getProcessor().setThreshold(128,255,ImageProcessor.NO_LUT_UPDATE)
roi = ThresholdToSelection.run(imp)
proi = new PolygonRoi(roi.getContainedFloatPoints(), Roi.POLYGON)
chRoi = new PolygonRoi(proi.getConvexHull(), Roi.POLYGON)
imp.setRoi(chRoi)

Note that in general, this type of question might be considered off-topic here and is better asked on the ImageJ forum, where you'll get advice from image processing experts.

Jan Eglinger
  • 3,995
  • 1
  • 25
  • 51
  • Thank you, I've written my own script. – Ivan Z Mar 20 '18 at 11:43
  • 1
    @IvanZ would you mind sharing how you solved it in the end? Maybe as a new answer to this question? I'd be interested to see how others tackle this. – Jan Eglinger Mar 20 '18 at 14:36
  • For others interested in this topic: see also [this ImageJ forum discussion](http://forum.imagej.net/t/merge-rois-into-one-big-one-bounding-n-polyline/9742?u=imagejan) for related questions. – Jan Eglinger Mar 20 '18 at 14:40
0

Edit-Selection-make selection, then ConvexHull

mendel
  • 1
  • 8