imageJ如何获得像素rgb值?

时间:2013-04-22 14:56:28

标签: java imagej

我有一个保存多边形坐标的简单插件:

Roi roi = imp.getRoi();
Polygon p = roi.getPolygon();
for (int i = 1; i <= p.npoints; i++) {
// létrehozzuk az onvif féle vector-t
org.onvif.ver10.schema.Vector myVector = new Vector();
myVector.setX((float) p.xpoints[i - 1]);
myVector.setY((float) p.ypoints[i - 1]);
op.getPoint().add(myVector);
// IJ.log("Vector X Elements " + i + " :" + MyVector.getX());

        }

但我想得到坐标rgb值如下: enter image description here

你能帮我解决这个问题吗? 谢谢!

2 个答案:

答案 0 :(得分:2)

假设图像是32位RGB:

ImagePlus im = IJ.getImage();
ImageProcessor imp = im.getProcessor();

int[] rgb = new int[3];
imp.getPixel(X,Y,rgb);

IJ.log(Arrays.toString(rgb));

答案 1 :(得分:0)

int[] r;

        for (int i = 1; i <= p.npoints; i++) {

            r = imp.getPixel(p.xpoints[i - 1], p.ypoints[i - 1]);



            ij.IJ.log("Red: "+ r[0]);
            ij.IJ.log("Green: "+ r[1]);
            ij.IJ.log("Blue: "+ r[2]);
            ij.IJ.log("index: "+ r[3]);

        }