type-conversiondm-script

Any Better Way to Convert a Float Image to an Integer Image?


I'm working with Gatan Script and currently need to convert a rotated float image to an integer image. I’m using the following code:

Image img := GetFrontImage()
Number rot_angle_rad = 30/(180/pi())
Image rotate_img = img.Rotate(rot_angle_rad)
Number sx, sy
rotate_img.GetSize(sx, sy)
Image inte_img := IntegerImage("tempImage", 2, 0, sx, sy)
inte_img = rotate_img
inte_img.ShowImage()

However, I'm not sure if this is the most efficient or recommended approach. I’ve already tried this method, but I'm concerned it might not be optimal in terms of performance or clarity.

My questions are:

Any insights, improvements, or alternative methods would be greatly appreciated.


Solution

  • There are specific ConvertTo methods that do that in-place. Fresh from the F1 help documentation:

    enter image description here

    Number rot_angle_rad = 30/(180/pi())
    Image img := GetFrontImage()
    Image int_img := img.Rotate(rot_angle_rad)
    int_img.ConvertToLong()
    int_img.ShowImage()