Resize images

//////GUI interface for changing the pixel dimensions of image data
///// opens with the current pixels
///// Uses bilinear interpolation to change size
//// outputs new wave with "_SZ" appended
//// Menu call in analysis menu


function Resize()
   
        string inputwave                        // for input wave
   
    string list=wavelist("*",";","DIMS:3")          // only find image stacks

    prompt inputwave, "Wave Select", popup list // prompt for input wave
    doprompt "Resize", inputwave
            if(V_flag==1)
            abort
        endif
   
    wave input=$inputwave  
       
    variable x=dimsize(input,0)             // current size of the x dimension
    variable y=dimsize(input,1)             // current size of the y dimension
   
    variable xnew = x                           // variables for the new pixels, set to display the old ones in the prompt
    variable ynew = y
   
    prompt xnew, "new x pixels"        
    prompt ynew, "new y pixels"
    doprompt "new dimensions", xnew, ynew
            if(V_flag==1)
            abort
        endif
       
    string newname=inputwave+"_SZ"          // output wave name
   
    variable nx= (xnew-1)/(x-1)                 // calc for rescaling
    variable ny=(ynew-1)/(y-1)
       
       
    imageinterpolate/F={nx,ny}/DEST=$newname bilinear input   // image interpolation
   

    end
   

Menu "Analysis"
            "Resize....", Resize()
End

Forum

Support

Gallery

Igor Pro 8

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More