0

将 DigitalMicrograph 从 GMS 1.x 更新到 GMS 2.x 后,无法保存自定义颜色表。任何人都知道如何在 DigitalMicrograph GMS 2.x 下保存自定义颜色表?

4

1 回答 1

0

这不一定是脚本问题,但可以通过脚本解决。它实际上似乎是 DigitalMicrograph 版本 GMS 2.x 中的一个错误。自定义颜色表存储在文件位置

C:\Users\_USERNAME_\AppData\Local\Gatan\ColorTables\

您可以使用以下命令获取此目录路径:

GetApplicationDirectory("user_color_table",0)

从 GMS 2.x 开始,颜色表以文件格式 *.dm4 存储。不幸的是,自定义颜色表的下拉列表仅列出格式为 *.dm3 的文件条目。(显然是一个错误。)要使其再次工作,请在该文件夹中保存颜色表两次。一次使用 *.dm3 扩展名,一次使用 *.dm4 扩展名。

您可以使用以下脚本以自定义名称存储现有图像的颜色表:

Image img 
if ( !GetFrontImage( img ) ) exit( 0 )
Image CLUT := img.ImageGetImageDisplay( 0 ).ImageDisplayGetInputColorTable()
String path = GetApplicationDirectory( "user_color_table" , 1 ) 
String name
If ( !GetString( "Enter name", img.GetName(), name ) ) exit( 0 )

CLUT.SaveAsGatan( PathConcatenate( path , name ) )    // Save as DM4
CLUT.SaveAsGatan3( PathConcatenate( path , name ) )   // Save again as DM3

请注意,您还可以使用脚本为图像设置特定的颜色表,而不是使用存储/命名的颜色表。参见示例:

创建一个颜色查找表 (CLUT) 作为 16x16 RGB 图像:

RGBImage CreateCLUT()
{
  image r1, g1, b1
  number nr, ng, nb, x, y, i, j, count 
  r1 = IntegerImage( "r", 4, 0, 16, 16 )
  g1 = IntegerImage( "g", 4, 0, 16, 16 )
  b1 = IntegerImage( "b", 4, 0, 16, 16 )
  for ( j = 0; j < 16; j++ ) for( i = 0; i < 16; i++ )
  {
    count = I * 16 + j
    nr = 0; ng = ( 255 - count ) * 4;  nb = ( count - 191 ) * 4;
    if ( count <= 191 )
    {
      nr = ( 191 - count ) * 4;  ng = 255; nb = ( 191 - count ) * 4;
    }
    if ( count <= 127 )
    {
      nr = 255;  ng = ( count - 63 ) * 4; nb = ( count - 63 ) * 4;
    }
    if ( count <= 63 )
    {
      nr = 255; ng = 255 - count * 4;  nb = 0;
    }
    SetPixel( r1, j, i, nr )
    SetPixel( g1, j, i, ng )
    SetPixel( b1, j, i, nb )
  }
  return rgb( r1, g1, b1 ) 
}

将 CLUT 图像设置为图像。(确保它首先显示为 RasterDisplay。):

Number SetClut( Image img, Image CLUT )
{
  if ( !img.ImageIsValid() ) return 0
  if ( 0 == img.ImageCountImageDisplays() ) return 0
  ImageDisplay disp = img.ImageGetImageDisplay(0)
  if ( 1 != disp.ImageDisplayGetDisplayType() ) return 0
  disp.ImageDisplaySetInputColorTable( CLUT )
  return 1
}

image img
if ( !GetFrontImage( img ) ) exit( 0 )
SetClut( img, CreateCLUT() )
于 2014-09-19T07:33:32.253 回答