2013-05-13 303 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