|
| 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: DemonsRegistration1/DemonsRegistration1.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">DemonsRegistration1/DemonsRegistration1.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="comment">// A SimpleITK example demonstrating the classic Demons image registration.</span></div> |
| 103 | +<div class="line"> </div> |
| 104 | +<div class="line"><span class="keyword">import</span> org.itk.simple.Image;</div> |
| 105 | +<div class="line"><span class="keyword">import</span> org.itk.simple.SimpleITK;</div> |
| 106 | +<div class="line"><span class="keyword">import</span> org.itk.simple.HistogramMatchingImageFilter;</div> |
| 107 | +<div class="line"><span class="keyword">import</span> org.itk.simple.DemonsRegistrationFilter;</div> |
| 108 | +<div class="line"><span class="keyword">import</span> org.itk.simple.Transform;</div> |
| 109 | +<div class="line"><span class="keyword">import</span> org.itk.simple.PixelIDValueEnum;</div> |
| 110 | +<div class="line"><span class="keyword">import</span> org.itk.simple.EventEnum;</div> |
| 111 | +<div class="line"><span class="keyword">import</span> org.itk.simple.Command;</div> |
| 112 | +<div class="line"> </div> |
| 113 | +<div class="line"><span class="keyword">public</span> <span class="keyword">class </span>DemonsRegistration1 {</div> |
| 114 | +<div class="line"> <span class="keyword">public</span> <span class="keyword">static</span> <span class="keywordtype">void</span> main(String[] args) {</div> |
| 115 | +<div class="line"> <span class="keywordflow">if</span> (args.length < 3) {</div> |
| 116 | +<div class="line"> System.out.println(<span class="stringliteral">"Usage: DemonsRegistration1 <fixedImageFile> <movingImageFile> <outputTransformFile>"</span>);</div> |
| 117 | +<div class="line"> System.exit(1);</div> |
| 118 | +<div class="line"> }</div> |
| 119 | +<div class="line"> </div> |
| 120 | +<div class="line"> <span class="comment">// Read the fixed and moving images as float32</span></div> |
| 121 | +<div class="line"> Image fixed = SimpleITK.readImage(args[0], PixelIDValueEnum.sitkFloat32);</div> |
| 122 | +<div class="line"> Image moving = SimpleITK.readImage(args[1], PixelIDValueEnum.sitkFloat32);</div> |
| 123 | +<div class="line"> </div> |
| 124 | +<div class="line"> <span class="comment">// Perform histogram matching of the moving image to the fixed image</span></div> |
| 125 | +<div class="line"> HistogramMatchingImageFilter matcher = <span class="keyword">new</span> HistogramMatchingImageFilter();</div> |
| 126 | +<div class="line"> matcher.setNumberOfHistogramLevels(1024);</div> |
| 127 | +<div class="line"> matcher.setNumberOfMatchPoints(7);</div> |
| 128 | +<div class="line"> matcher.thresholdAtMeanIntensityOn();</div> |
| 129 | +<div class="line"> moving = matcher.execute(moving, fixed);</div> |
| 130 | +<div class="line"> </div> |
| 131 | +<div class="line"> <span class="comment">// The basic Demons Registration Filter</span></div> |
| 132 | +<div class="line"> <span class="comment">// Note there is a whole family of Demons Registration algorithms included in SimpleITK</span></div> |
| 133 | +<div class="line"> DemonsRegistrationFilter demons = <span class="keyword">new</span> DemonsRegistrationFilter();</div> |
| 134 | +<div class="line"> demons.setNumberOfIterations(50);</div> |
| 135 | +<div class="line"> <span class="comment">// Standard deviation for Gaussian smoothing of displacement field</span></div> |
| 136 | +<div class="line"> demons.setStandardDeviations(1.0);</div> |
| 137 | +<div class="line"> </div> |
| 138 | +<div class="line"> <span class="comment">// Add iteration callback</span></div> |
| 139 | +<div class="line"> IterationUpdate cmd = <span class="keyword">new</span> IterationUpdate(demons);</div> |
| 140 | +<div class="line"> demons.addCommand(EventEnum.sitkIterationEvent, cmd);</div> |
| 141 | +<div class="line"> </div> |
| 142 | +<div class="line"> Image displacementField = demons.execute(fixed, moving);</div> |
| 143 | +<div class="line"> </div> |
| 144 | +<div class="line"> System.out.println(<span class="stringliteral">"-------"</span>);</div> |
| 145 | +<div class="line"> System.out.println(<span class="stringliteral">"Number Of Iterations: "</span> + demons.getElapsedIterations());</div> |
| 146 | +<div class="line"> System.out.println(<span class="stringliteral">" RMS: "</span> + demons.getRMSChange());</div> |
| 147 | +<div class="line"> </div> |
| 148 | +<div class="line"> <span class="comment">// Create and write the displacement field transform</span></div> |
| 149 | +<div class="line"> Transform outTx = <span class="keyword">new</span> org.itk.simple.DisplacementFieldTransform(displacementField);</div> |
| 150 | +<div class="line"> SimpleITK.writeTransform(outTx, args[2]);</div> |
| 151 | +<div class="line"> }</div> |
| 152 | +<div class="line"> </div> |
| 153 | +<div class="line"> <span class="comment">// Callback class for iteration events</span></div> |
| 154 | +<div class="line"> <span class="keyword">static</span> <span class="keyword">class </span>IterationUpdate <span class="keyword">extends</span> Command {</div> |
| 155 | +<div class="line"> <span class="keyword">private</span> DemonsRegistrationFilter filter;</div> |
| 156 | +<div class="line"> </div> |
| 157 | +<div class="line"> <span class="keyword">public</span> IterationUpdate(DemonsRegistrationFilter filter) {</div> |
| 158 | +<div class="line"> super();</div> |
| 159 | +<div class="line"> this.filter = filter;</div> |
| 160 | +<div class="line"> }</div> |
| 161 | +<div class="line"> </div> |
| 162 | +<div class="line"> <span class="keyword">public</span> <span class="keywordtype">void</span> execute() {</div> |
| 163 | +<div class="line"> System.out.format(<span class="stringliteral">"%3d = %10.5f\n"</span>, filter.getElapsedIterations(), filter.getMetric());</div> |
| 164 | +<div class="line"> }</div> |
| 165 | +<div class="line"> }</div> |
| 166 | +<div class="line">}</div> |
| 167 | +</div><!-- fragment --> </div><!-- contents --> |
| 168 | +<!-- HTML footer for doxygen 1.8.17--> |
| 169 | +<!-- start footer part --> |
| 170 | +<hr class="footer"/><address class="footer"><small> |
| 171 | + Generated on <span id="datetime">unknown</span> for SimpleITK by   |
| 172 | + <a href="http://www.doxygen.org/index.html"> |
| 173 | +<img class="footer" src="doxygen.png" alt="doxygen"/> |
| 174 | +</a> 1.13.2 | <a href="https://simpleitk.org/privacy_policy.html"> |
| 175 | + Privacy Policy</a> |
| 176 | +</small></address> |
| 177 | +</body> |
| 178 | +</html> |
0 commit comments