如何在图像中复制切片?

时间:2017-04-25 05:54:17

标签: slice dm-script

我想制作包含多个切片的正面图像的副本,如下所示:  image with several slices 我使用了imageclone函数

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

但它只复制第一片。 有谁知道如何制作这种图像的副本>“< 非常感谢〜

2 个答案:

答案 0 :(得分:2)

复制图像的最简单方法(无论它是如何显示的)是通过它的"容器" - ImageDocument。以下是代码:

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

如果你需要操纵单个切片,那么它就更复杂了。希望这会有所帮助。

答案 1 :(得分:1)

在接受(正确和最佳)答案的延伸中,值得知道如何来自"图像"到它的imageDocument。你在这个例子中这样做:

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。

取决于"深度"您需要了解所有这些,我建议您阅读文档部分" image / imageDocument / imageDisplay / components"并测试一下。如果问题仍然存在,请在StackOverflow上发布:c)

相关问题