|
| 1 | +<!-- HTML header for doxygen 1.8.17--> |
| 2 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | +<html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 | +<head> |
| 5 | +<!-- Google Tag Manager --> |
| 6 | +<script> |
| 7 | + (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push( |
| 8 | + {'gtm.start': new Date().getTime(),event:'gtm.js'} |
| 9 | + );var f=d.getElementsByTagName(s)[0], |
| 10 | + j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= |
| 11 | + 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); |
| 12 | + })(window,document,'script','dataLayer','GTM-N38XC8T'); |
| 13 | +</script> |
| 14 | +<!-- End Google Tag Manager --> |
| 15 | +<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> |
| 16 | +<meta http-equiv="X-UA-Compatible" content="IE=9"/> |
| 17 | +<meta name="generator" content="Doxygen 1.13.2"/> |
| 18 | +<meta name="viewport" content="width=device-width, initial-scale=1"/> |
| 19 | +<title>SimpleITK: ImageRegistrationMethod2/ImageRegistrationMethod2.java</title> |
| 20 | +<link href="tabs.css" rel="stylesheet" type="text/css"/> |
| 21 | +<script type="text/javascript" src="jquery.js"></script> |
| 22 | +<script type="text/javascript" src="dynsections.js"></script> |
| 23 | +<link href="navtree.css" rel="stylesheet" type="text/css"/> |
| 24 | +<script type="text/javascript" src="resize.js"></script> |
| 25 | +<script type="text/x-mathjax-config"> |
| 26 | +MathJax.Hub.Config({ |
| 27 | + extensions: ["tex2jax.js"], |
| 28 | + jax: ["input/TeX","output/HTML-CSS"], |
| 29 | +}); |
| 30 | +</script> |
| 31 | +<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js"></script> |
| 32 | +<link href="doxygen.css" rel="stylesheet" type="text/css" /> |
| 33 | +<link href="customdoxygen.css" rel="stylesheet" type="text/css"/> |
| 34 | +</head> |
| 35 | +<body> |
| 36 | +<!-- Google Tag Manager (noscript) --> |
| 37 | +<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-N38XC8T" |
| 38 | + height="0" width="0" style="display:none;visibility:hidden"></iframe> |
| 39 | +</noscript> |
| 40 | +<!-- End Google Tag Manager (noscript) --> |
| 41 | +<script type="text/javascript" src="build_text.js"></script> |
| 42 | +<div id="top"><!-- do not remove this div, it is closed by doxygen! --> |
| 43 | +<div id="titlearea"> |
| 44 | +<table cellspacing="0" cellpadding="0"> |
| 45 | + <tbody> |
| 46 | + <tr style="height: 56px;"> |
| 47 | + <td id="projectalign" style="padding-left: 0.5em;"> |
| 48 | + <div id="projectname">SimpleITK |
| 49 | +  <span id="projectnumber"></span> |
| 50 | + </div> |
| 51 | + </td> |
| 52 | + </tr> |
| 53 | + </tbody> |
| 54 | +</table> |
| 55 | +</div> |
| 56 | +<!-- end header part --> |
| 57 | +<!-- Generated by Doxygen 1.13.2 --> |
| 58 | +<script type="text/javascript"> |
| 59 | +/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ |
| 60 | +$(function() { codefold.init(0); }); |
| 61 | +/* @license-end */ |
| 62 | +</script> |
| 63 | +<script type="text/javascript" src="menudata.js"></script> |
| 64 | +<script type="text/javascript" src="menu.js"></script> |
| 65 | +<script type="text/javascript"> |
| 66 | +/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ |
| 67 | +$(function() { |
| 68 | + initMenu('',false,false,'search.php','Search',false); |
| 69 | +}); |
| 70 | +/* @license-end */ |
| 71 | +</script> |
| 72 | +<div id="main-nav"></div> |
| 73 | +</div><!-- top --> |
| 74 | +<div id="doc-content"> |
| 75 | +<script type="text/javascript"> |
| 76 | +/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ |
| 77 | +$(function(){ initResizable(false); }); |
| 78 | +/* @license-end */ |
| 79 | +</script> |
| 80 | +<div class="header"> |
| 81 | + <div class="headertitle"><div class="title">ImageRegistrationMethod2/ImageRegistrationMethod2.java</div></div> |
| 82 | +</div><!--header--> |
| 83 | +<div class="contents"> |
| 84 | +<div class="fragment"><div class="line"><span class="comment">/*=========================================================================</span></div> |
| 85 | +<div class="line"><span class="comment"> *</span></div> |
| 86 | +<div class="line"><span class="comment"> * Copyright NumFOCUS</span></div> |
| 87 | +<div class="line"><span class="comment"> *</span></div> |
| 88 | +<div class="line"><span class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</span></div> |
| 89 | +<div class="line"><span class="comment"> * you may not use this file except in compliance with the License.</span></div> |
| 90 | +<div class="line"><span class="comment"> * You may obtain a copy of the License at</span></div> |
| 91 | +<div class="line"><span class="comment"> *</span></div> |
| 92 | +<div class="line"><span class="comment"> * http://www.apache.org/licenses/LICENSE-2.0.txt</span></div> |
| 93 | +<div class="line"><span class="comment"> *</span></div> |
| 94 | +<div class="line"><span class="comment"> * Unless required by applicable law or agreed to in writing, software</span></div> |
| 95 | +<div class="line"><span class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</span></div> |
| 96 | +<div class="line"><span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div> |
| 97 | +<div class="line"><span class="comment"> * See the License for the specific language governing permissions and</span></div> |
| 98 | +<div class="line"><span class="comment"> * limitations under the License.</span></div> |
| 99 | +<div class="line"><span class="comment"> *</span></div> |
| 100 | +<div class="line"><span class="comment"> *=========================================================================*/</span></div> |
| 101 | +<div class="line"> </div> |
| 102 | +<div class="line"><span class="keyword">import</span> org.itk.simple.*;</div> |
| 103 | +<div class="line"><span class="keyword">import</span> java.text.DecimalFormat;</div> |
| 104 | +<div class="line"> </div> |
| 105 | +<div class="line"><span class="keyword">class </span>IterationUpdate <span class="keyword">extends</span> Command {</div> |
| 106 | +<div class="line"> <span class="keyword">private</span> ImageRegistrationMethod method;</div> |
| 107 | +<div class="line"> </div> |
| 108 | +<div class="line"> <span class="keyword">public</span> IterationUpdate(ImageRegistrationMethod m) {</div> |
| 109 | +<div class="line"> method = m;</div> |
| 110 | +<div class="line"> }</div> |
| 111 | +<div class="line"> </div> |
| 112 | +<div class="line"> <span class="keyword">public</span> <span class="keywordtype">void</span> execute() {</div> |
| 113 | +<div class="line"> VectorDouble pos = method.getOptimizerPosition();</div> |
| 114 | +<div class="line"> DecimalFormat df = <span class="keyword">new</span> DecimalFormat(<span class="stringliteral">"0.00000"</span>);</div> |
| 115 | +<div class="line"> System.out.println(String.format(<span class="stringliteral">"%3d = %10s : [%s, %s]"</span>,</div> |
| 116 | +<div class="line"> method.getOptimizerIteration(),</div> |
| 117 | +<div class="line"> df.format(method.getMetricValue()),</div> |
| 118 | +<div class="line"> df.format(pos.get(0)), df.format(pos.get(1))));</div> |
| 119 | +<div class="line"> }</div> |
| 120 | +<div class="line">}</div> |
| 121 | +<div class="line"> </div> |
| 122 | +<div class="line"><span class="keyword">public</span> <span class="keyword">class </span>ImageRegistrationMethod2 {</div> |
| 123 | +<div class="line"> </div> |
| 124 | +<div class="line"> <span class="keyword">public</span> <span class="keyword">static</span> <span class="keywordtype">void</span> main(String[] args) <span class="keywordflow">throws</span> Exception {</div> |
| 125 | +<div class="line"> <span class="keywordflow">if</span> (args.length < 3) {</div> |
| 126 | +<div class="line"> System.out.println(<span class="stringliteral">"Usage: ImageRegistrationMethod2 <fixedImageFile> <movingImageFile> <outputTransformFile>"</span>);</div> |
| 127 | +<div class="line"> System.exit(1);</div> |
| 128 | +<div class="line"> }</div> |
| 129 | +<div class="line"> </div> |
| 130 | +<div class="line"> ImageFileReader reader = <span class="keyword">new</span> ImageFileReader();</div> |
| 131 | +<div class="line"> reader.setOutputPixelType(<a class="code hl_enumeration" href="namespaceitk_1_1simple.html#ae40bd64640f4014fba1a8a872ab4df98">PixelIDValueEnum</a>.sitkFloat32);</div> |
| 132 | +<div class="line"> </div> |
| 133 | +<div class="line"> reader.setFileName(args[0]);</div> |
| 134 | +<div class="line"> Image fixedImage = reader.execute();</div> |
| 135 | +<div class="line"> fixedImage = SimpleITK.normalize(fixedImage);</div> |
| 136 | +<div class="line"> fixedImage = SimpleITK.discreteGaussian(fixedImage, 2.0);</div> |
| 137 | +<div class="line"> </div> |
| 138 | +<div class="line"> reader.setFileName(args[1]);</div> |
| 139 | +<div class="line"> Image movingImage = reader.execute();</div> |
| 140 | +<div class="line"> movingImage = SimpleITK.normalize(movingImage);</div> |
| 141 | +<div class="line"> movingImage = SimpleITK.discreteGaussian(movingImage, 2.0);</div> |
| 142 | +<div class="line"> </div> |
| 143 | +<div class="line"> ImageRegistrationMethod R = <span class="keyword">new</span> ImageRegistrationMethod();</div> |
| 144 | +<div class="line"> R.setMetricAsJointHistogramMutualInformation();</div> |
| 145 | +<div class="line"> </div> |
| 146 | +<div class="line"> <span class="keywordtype">double</span> learningRate = 1.0;</div> |
| 147 | +<div class="line"> <span class="keywordtype">int</span> numberOfIterations = 200;</div> |
| 148 | +<div class="line"> <span class="keywordtype">double</span> convergenceMinimumValue = 1e-4;</div> |
| 149 | +<div class="line"> <span class="keywordtype">int</span> convergenceWindowSize = 5;</div> |
| 150 | +<div class="line"> </div> |
| 151 | +<div class="line"> R.setOptimizerAsGradientDescentLineSearch(learningRate,</div> |
| 152 | +<div class="line"> numberOfIterations,</div> |
| 153 | +<div class="line"> convergenceMinimumValue,</div> |
| 154 | +<div class="line"> convergenceWindowSize);</div> |
| 155 | +<div class="line"> </div> |
| 156 | +<div class="line"> R.setInitialTransform(<span class="keyword">new</span> TranslationTransform(fixedImage.getDimension()));</div> |
| 157 | +<div class="line"> R.setInterpolator(<a class="code hl_enumeration" href="namespaceitk_1_1simple.html#a7cb1ef8bd02c669c02ea2f9f5aa374e5">InterpolatorEnum</a>.sitkLinear);</div> |
| 158 | +<div class="line"> </div> |
| 159 | +<div class="line"> IterationUpdate cmd = <span class="keyword">new</span> IterationUpdate(R);</div> |
| 160 | +<div class="line"> R.addCommand(<a class="code hl_enumeration" href="namespaceitk_1_1simple.html#aa7399868984d99493c5a307cce373ace">EventEnum</a>.sitkIterationEvent, cmd);</div> |
| 161 | +<div class="line"> </div> |
| 162 | +<div class="line"> Transform outTx = R.execute(fixedImage, movingImage);</div> |
| 163 | +<div class="line"> </div> |
| 164 | +<div class="line"> outTx.writeTransform(args[2]);</div> |
| 165 | +<div class="line"> }</div> |
| 166 | +<div class="line">}</div> |
| 167 | +<div class="ttc" id="anamespaceitk_1_1simple_html_a7cb1ef8bd02c669c02ea2f9f5aa374e5"><div class="ttname"><a href="namespaceitk_1_1simple.html#a7cb1ef8bd02c669c02ea2f9f5aa374e5">itk::simple::InterpolatorEnum</a></div><div class="ttdeci">InterpolatorEnum</div><div class="ttdef"><b>Definition</b> <a href="sitkInterpolator_8h_source.html#l00028">sitkInterpolator.h:29</a></div></div> |
| 168 | +<div class="ttc" id="anamespaceitk_1_1simple_html_aa7399868984d99493c5a307cce373ace"><div class="ttname"><a href="namespaceitk_1_1simple.html#aa7399868984d99493c5a307cce373ace">itk::simple::EventEnum</a></div><div class="ttdeci">EventEnum</div><div class="ttdoc">Events which can be observed from ProcessObject.</div><div class="ttdef"><b>Definition</b> <a href="sitkEvent_8h_source.html#l00031">sitkEvent.h:32</a></div></div> |
| 169 | +<div class="ttc" id="anamespaceitk_1_1simple_html_ae40bd64640f4014fba1a8a872ab4df98"><div class="ttname"><a href="namespaceitk_1_1simple.html#ae40bd64640f4014fba1a8a872ab4df98">itk::simple::PixelIDValueEnum</a></div><div class="ttdeci">PixelIDValueEnum</div><div class="ttdoc">Enumerated values of pixelIDs.</div><div class="ttdef"><b>Definition</b> <a href="sitkPixelIDValues_8h_source.html#l00100">sitkPixelIDValues.h:101</a></div></div> |
| 170 | +</div><!-- fragment --> </div><!-- contents --> |
| 171 | +<!-- HTML footer for doxygen 1.8.17--> |
| 172 | +<!-- start footer part --> |
| 173 | +<hr class="footer"/><address class="footer"><small> |
| 174 | + Generated on <span id="datetime">unknown</span> for SimpleITK by   |
| 175 | + <a href="http://www.doxygen.org/index.html"> |
| 176 | +<img class="footer" src="doxygen.png" alt="doxygen"/> |
| 177 | +</a> 1.13.2 | <a href="https://simpleitk.org/privacy_policy.html"> |
| 178 | + Privacy Policy</a> |
| 179 | +</small></address> |
| 180 | +</body> |
| 181 | +</html> |
0 commit comments