1

我想制作包含多个切片的正面图像的副本,如下所示: 带有多个切片的图像 我使用了 imageclone 功能

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

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

4

2 回答 2

2

复制图像(不管它如何显示)的最简单方法是通过它的“容器”——ImageDocument。以下是代码:

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

如果您需要操作单个切片,那么它会更复杂。希望这可以帮助。

于 2017-04-26T14:24:30.953 回答
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 可能包含多个图像(或没有)。

这有点令人费解,而且看起来令人困惑,因为内部类层次结构之后的许多“正确”命令都被简化命令包装以方便编写脚本。

fe 保存图像 usingSaveSave()需要一个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)

于 2017-04-28T07:53:11.037 回答