2017-04-25 108 views
1

我想使正面圖像的副本,其包含若干片,這樣的: image with several slices 我用imageclone功能如何複製圖像中的切片?

image front, img 
front.getfrontimage() 
img=imageclone(front) 
img.showimage() 

但它只是複製的第一個切片。 有任何人知道如何使這種圖像>的副本」 < 非常感謝〜

回答

2

複製的圖像(它是不管如何顯示)是通過其最簡單的方法‘容器’ - ImageDocument這裏是代碼:。

ImageDocument imgDoc = GetFrontImageDocument(); 
number DoDeepCopy = 1; 
ImageDocument newDoc = imgDoc.ImageDocumentClone(DoDeepCopy); 
newDoc.ImageDocumentShow(); 

如果你需要操縱單個切片話,那就更復雜的希望這有助於

+0

非常感謝。現在我知道我應該將圖像作爲圖像文檔處理,當我在圖像中添加切片時。 – Renfong

+0

@Renfong:我不知道這(在一個問題總是好的,說明這點)GMS您正在使用的版本,但在最新的大湄公河次區域安裝有相當多的「示例腳本」在F1幫助部分linePlots「腳本/示例腳本/數據顯示「關於linePlot類型的圖像。 – BmyGuest

+0

@BmyGuest,我使用GMS 3.20。非常感謝^^下次我會記住它。 – Renfong

1

在擴展到接受(正確的和最佳)的答案,這是值得知道如何來從「圖像」到它的imageDocument,你在這個e中就像這樣做xample:

ClearResults() 

image frontImg := GetFrontImage() 
imageDocument frontDoc = GetFrontImageDocument() 
Result("Grapped from application:") 
Result("\n\t Image: " + frontImg.ImageGetLabel() + "\t ID = " + frontImg.ImageGetID()) 
Result("\n\t Doc : " + frontDoc.ImageDocumentGetName() + "\t ID = " + frontDoc.ImageDocumentGetID()) 

imageDocument docFromImg = frontImg.ImageGetOrCreateImageDocument() 
Result("\n Taken from image:") 
Result("\n\t Doc : " + frontDoc.ImageDocumentGetName() + "\t ID = " + docFromImg.ImageDocumentGetID()) 

image imgFromDoc := frontDoc.ImageDocumentGetImage(0) 
Result("\n Taken from imageDocument:") 
Result("\n\t Image: " + frontImg.ImageGetLabel() + "\t ID = " + imgFromDoc.ImageGetID()) 

注意,圖像不一定的imageDocument。 imageDocument僅在圖像顯示或保存時創建。這就是爲什麼該命令被稱爲...GetOrCreate

同樣,imageDocument可能包含多個圖像(或沒有)。

這是所有位旋繞,並且因爲許多以下的內部的類層次結構的「正確」的命令被簡化命令的腳本方便包裹它出現混亂。

f.e.使用SaveSave()保存圖像需要image變量,但它確實需要保存imageDocument。所以它隱含地獲取/創建一個。否則,用戶需要編寫正確,但更復雜的腳本。
相反的:

string path = "C:\\test.dm4" 
image img := GetFrontImage() 
img.SaveImage(path) 

一個需要:

string path = "C:\\test.dm4" 
string handler = "Gatan Format" 
image img := GetFrontImage() 
imageDocument doc = img.ImageGetOrCreateImageDocument() 
doc.ImageDocumentSaveToFile(handler, path) 

還要注意:在使用imageDocuments的路線是正確的方法,你應該知道,「linePlot顯示」是非常特殊的。它們是可能包含多個圖像的imageDisplay對象,而imageDocuments是可能包含多個imageDisplay的對象。我指出了這一點,以便您知道需要將新圖像添加到imageDisplay以在切片圖像中獲取更多切片。如果將它們添加到imageDocument中,則會在單個文件中顯示多個linePlot顯示。

取決於你需要如何「深」就知道這一切,我會建議閱讀「圖像/ imageDocument/imageDisplay /組件」和測試事情有點文檔部分。如果問題仍然存在,請在StackOverflow上發佈:c)