2012-09-03 119 views
0

使用ImageJ api,我试图保存一个合成图像,由几个并排布置的图像组成。ImageJ API:合并图像

我有代码加载ImagePlus objs,并保存它们。但我无法确定如何将图像粘贴到其他图像中。

+0

它们是否具有相同的尺寸? –

回答

0

我将问题解释为拍摄多张图像并将它们并排拼接在一起形成一个大图像,其中图像可能有不同的尺寸。以下不完整的代码是实现它的一种方式,应该让你开始。

public ImagePlus composeImages(ArrayList<ImagePlus> imageList){ 
    int sumWidth = 0; 
    int maxHeight = 0; 

    for(ImagePlus imp : imageList){ 
     sumWidth = sumWidth +imp.getWidth(); 
     if(imp.getHeight() > maxHeight) 
      maxHeight = imp.getWidth(); 

    } 

    ImagePlus impComposite = new ImagePlus(); 

    ImageProcessor ipComposite = new ShortProcessor(sumWidth, maxHeight); 

    for(int i=0; i<sumWidth; i++){ 
     for(int j=0; j<sumWidth; j++){ 

      ipComposite.putPixelValue(i, j, figureOutThis); 

     } 
    } 

    impComposite.setProcessor(ipComposite); 
    return impComposite; 

} 

你需要写一个算法来找出像素值(figureOutThis)把合成图像在ij。如果所有图像具有相同的宽度并且其他工作稍微多一点,那么这很简单。快乐编码

编辑: 我应该补充一点,我假设他们也都是短的图像(我工作与医疗灰度)。您可以对其他处理器进行修改