1064 posts
|
On Dec 14, 2012, at 6:08 AM, Thorsten Wagner wrote:
> Hi
> i've used a contour tracing algorithm to extracted the contour of the following object:
> https://dl.dropbox.com/u/560426/imagej/object.png>
> The extracted polygon is described by the following points:
> int[] xpoints = {3,4,5,6,7,8,9,10,11,11,11,10,9,8,7,6,5,4,3,2,2,2,3};
> int[] ypoints = {1,1,2,2,2,1,1,2,2,3,4,4,5,5,4,4,4,5,5,4,3,2,1};
> These Points seems to be correct.
>
> I've now converted this polygon to a PolygonRoi and add it to the RoiManager:
> Roi roi = new PolygonRoi(mypolygon, Roi.POLYGON);
> roiManager.add(imp, roi, n);
>
> If I click on the added Roi in the ROI-Manager the overlayed contour is smaller than expected:
> https://dl.dropbox.com/u/560426/imagej/contour_imagej.pngThe overlaid contour will look better if you place the polygon vertices at pixel centers by adding 0.5 to the x and y coordinates of the contour pixels.
-wayne
float[] x = {3,4,5,6,7,8,9,10,11,11,11,10,9,8,7,6,5,4,3,2,2,2,3};
float[] y = {1,1,2,2,2,1,1,2,2,3,4,4,5,5,4,4,4,5,5,4,3,2,1};
n = x.length;
for (i=0; i<n; i++) {
x[i] += 0.5f;
y[i] += 0.5f;
}
roi = new PolygonRoi(x, y, n, Roi.POLYGON);
imp = IJ.getImage();
imp.setRoi(roi);
[cid: [hidden email]]
[cid: [hidden email]]
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
|