We develop a new method with a global optimization for registering films to calculate doses for intensity-modulated radiation therapy (IMRT) and intensity-modulated radiosurgery (IMRS) quality assurance (QA). Both absolute point dosimetry and two-dimensional (2D) film dosimetry are performed through the IMRT and IMRS using Clinac 21EX's 120 millenium MLC and BrainLab's micro-MLC, respectively. The measured and calculated dose distributions are superimposed by coincidence of their origins, followed by comparison of the point doses at all matched positions. Then, with the optimization algorithm the setup error of the dosimeter is corrected. An example of IMRT cases shows that the average percentage showing 3% of dose difference for 10 patients has been reduced from 19% to 9%, before and after optimization and weight, respectively. Similar results are obtained for IMRS. This method dramatically reduces the difference between measured and calculated dose distributions in all cases investigated.