[英]ImageJ API: Combining images
我試圖使用ImageJ api保存一個合成圖像,該圖像由並排放置的多個圖像組成。
我有加載ImagePlus objs並保存它們的代碼。 但是我不知道如何將一個圖像粘貼到另一個圖像中。
我將問題解釋為拍攝多張圖像並將它們並排縫合在一起以形成較大的圖像,其中圖像可能具有不同的尺寸。 以下不完整的代碼是執行此操作的一種方法,應該使您入門。
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;
}
您需要編寫一種算法來查找要放入合成圖像i
, j
的像素值( figureOutThis
)。 如果所有圖像都具有相同的寬度,否則工作量會很小。 快樂編碼
編輯:我應該補充一點,我假設它們都是短圖像(我使用醫學灰度)。 您可以為其他處理器修改它
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.