// @Auther : M.Hattori 2008.9.23
// Dicom画像のUnsharp_Masking処理
// kernel size　= 「7x7」


 run("Select None");

 rename("Org_Image");

 k=getNumber("E_coefficient",2);
 w=getWidth() ;
 h=getHeight() ;

 run("Duplicate...", "title=UnsharpImage");
 run("Convolve...", "text1=[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] normalize");
 
 imageCalculator("Subtract create", "Org_Image","UnsharpImage");
//run("Image Calculator...", "image1=Org_Image operation=Subtract image2=UnsharpImage creat");


 for (y=0;y<h;y++){
     for(x=0;x<w;x++){
         uspv=getPixel(x,y) ;
         if (uspv==0) { pv=0; }
                 else { pv=uspv*k; }
         setPixel(x,y,pv);
     }
  } 


 imageCalculator("Add create", "Org_Image","Result of Org_Image");
//run("Image Calculator...", "image1=Org_Image operation=Add image2=[Result of Org_Image] create");


 rename("USM_7x7_E"+k);
