2013-05-13 296 views
0

使用ImageJ我想为给定位置的ROI创建缩放功能。到目前为止,我有这样的事情:ImageJ叠加ROI缩放

imp = IJ.getImage(); 
ip = imp.getProcessor(); 
//fill pixel array with ROI pixels 
for(int i = 0; i < height; i++) 
{ 
for(int j = 0; j < width; j++) 
{ 
pixels[i][j] = (float)ip.getPixel(xPos + i, yPos + j); 
} 
} 

我有像素阵列,现在我想创建一个包含这些像素在我的形象的角落放大了投资回报率。我一直在研究ImageJ的ROI api,但似乎无法找到正确的方向。任何指导都会很棒。我正在寻找一个函数来填充我有像素值的ROI。提前致谢。

回答

1

您可能正在寻找类ImageRoi。此代码将在左上角的覆盖图中显示选定的roi(2倍大)。

ImageProcessor cropped = IJ.getImage().getProcessor().crop(); //image from currently selected roi 
ImageProcessor scaled = cropped.resize(cropped.getWidth()*2,cropped.getHeight()*2); //magnified image 
Overlay overlay = new Overlay(new ImageRoi(0,0, scaled));  
IJ.getImage().setOverlay(overlay); 
+0

我贴了我到目前为止的内容。再次感谢你的帮助。 – Elewis787 2013-05-15 14:01:28