// Script function: Resize an image by changing the number of pixels in an original image
// Requirement: Open an image

// Unless named starting with GlobalSino, EM, My, Self, the function commands are defined 
//by Gatan DM, please see at link: http://www.globalsino.com/EM/page2597.html


image GlobalSinoImage, ReSizedImage
GlobalSinoImage.GetFrontImage()
number EMx, EMy

GetSize( GlobalSinoImage, EMx, EMy )

TagGroup GlobalSino, EMItems
GlobalSino = DLGCreateDialog( "Please enter your resizing factor", EMItems )
 
TagGroup MyNumber
 
EMItems.DLGAddElement( DLGCreateRealField( "Resizing factor:", MyNumber, 0.5, 18, 3 ) )       
 
if ( !Alloc( UIframe ).Init( GlobalSino ).Pose() ) exit (0)
 
number EMfactor = MyNumber.DLGGetValue() 

ReSizedImage := ImageClone( GlobalSinoImage )

ImageResize( ReSizedImage, 2, EMx * EMfactor, EMy * EMfactor )

ReSizedImage = Warp( GlobalSinoImage, icol/EMfactor, irow/EMfactor )
// You can compare this script with the one, which has the same function, at http://www.globalsino.com/EM/page2597_Resize_image_3.s

SetName( ReSizedImage, GetName( GlobalSinoImage ) + "Resized Image" )

ShowImage( ReSizedImage )
 
