|
| 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: LandmarkRegistration/LandmarkRegistration.R</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">LandmarkRegistration/LandmarkRegistration.R</div></div> |
| 82 | +</div><!--header--> |
| 83 | +<div class="contents"> |
| 84 | +<div class="fragment"><div class="line"># =========================================================================</div> |
| 85 | +<div class="line">#</div> |
| 86 | +<div class="line"># Copyright NumFOCUS</div> |
| 87 | +<div class="line">#</div> |
| 88 | +<div class="line"># Licensed under the Apache License, Version 2.0 (the "License");</div> |
| 89 | +<div class="line"># you may not use this file except in compliance with the License.</div> |
| 90 | +<div class="line"># You may obtain a copy of the License at</div> |
| 91 | +<div class="line">#</div> |
| 92 | +<div class="line"># http://www.apache.org/licenses/LICENSE-2.0.txt</div> |
| 93 | +<div class="line">#</div> |
| 94 | +<div class="line"># Unless required by applicable law or agreed to in writing, software</div> |
| 95 | +<div class="line"># distributed under the License is distributed on an "AS IS" BASIS,</div> |
| 96 | +<div class="line"># WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</div> |
| 97 | +<div class="line"># See the License for the specific language governing permissions and</div> |
| 98 | +<div class="line"># limitations under the License.</div> |
| 99 | +<div class="line">#</div> |
| 100 | +<div class="line"># =========================================================================</div> |
| 101 | +<div class="line"> </div> |
| 102 | +<div class="line"># A SimpleITK example demonstrating landmark registration.</div> |
| 103 | +<div class="line"> </div> |
| 104 | +<div class="line">library(SimpleITK)</div> |
| 105 | +<div class="line"> </div> |
| 106 | +<div class="line">args <- commandArgs(TRUE)</div> |
| 107 | +<div class="line"> </div> |
| 108 | +<div class="line"># Black image with a small white square in it.</div> |
| 109 | +<div class="line">fixedImage <- Image(100, 100, 'sitkUInt8')</div> |
| 110 | +<div class="line"># Set pixels in rectangle [11:20, 11:20] to 200</div> |
| 111 | +<div class="line">for (x in 11:19) {</div> |
| 112 | +<div class="line"> for (y in 11:19) {</div> |
| 113 | +<div class="line"> fixedImage$SetPixel(c(x, y), 200)</div> |
| 114 | +<div class="line"> }</div> |
| 115 | +<div class="line">}</div> |
| 116 | +<div class="line"> </div> |
| 117 | +<div class="line"># Black image with a small grey square at a different location.</div> |
| 118 | +<div class="line">movingImage <- Image(100, 100, 'sitkUInt8')</div> |
| 119 | +<div class="line"># Set pixels in rectangle [51:60, 51:60] to 69</div> |
| 120 | +<div class="line">for (x in 51:59) {</div> |
| 121 | +<div class="line"> for (y in 51:59) {</div> |
| 122 | +<div class="line"> movingImage$SetPixel(c(x, y), 69)</div> |
| 123 | +<div class="line"> }</div> |
| 124 | +<div class="line">}</div> |
| 125 | +<div class="line"> </div> |
| 126 | +<div class="line"># Landmarks are 3 corners of the squares.</div> |
| 127 | +<div class="line"># 3 (X, Y) pairs are flattened into 1-d lists.</div> |
| 128 | +<div class="line">fixedLandmarks <- c(10, 10, 20, 10, 20, 20)</div> |
| 129 | +<div class="line">movingLandmarks <- c(50, 50, 60, 50, 60, 60)</div> |
| 130 | +<div class="line"> </div> |
| 131 | +<div class="line"># Set up the LandmarkBasedTransformInitializerFilter.</div> |
| 132 | +<div class="line">landmarkInitializer <- LandmarkBasedTransformInitializerFilter()</div> |
| 133 | +<div class="line"> </div> |
| 134 | +<div class="line">landmarkInitializer$SetFixedLandmarks(fixedLandmarks)</div> |
| 135 | +<div class="line">landmarkInitializer$SetMovingLandmarks(movingLandmarks)</div> |
| 136 | +<div class="line"> </div> |
| 137 | +<div class="line">transform <- Euler2DTransform()</div> |
| 138 | +<div class="line"> </div> |
| 139 | +<div class="line"># Compute the transform.</div> |
| 140 | +<div class="line">outputTransform <- landmarkInitializer$Execute(transform)</div> |
| 141 | +<div class="line"> </div> |
| 142 | +<div class="line">cat(outputTransform$ToString())</div> |
| 143 | +<div class="line"> </div> |
| 144 | +<div class="line"># Resample the transformed moving image onto the fixed image.</div> |
| 145 | +<div class="line">outputImage <- Resample(movingImage, fixedImage, outputTransform, 'sitkLinear', 150)</div> |
| 146 | +<div class="line"> </div> |
| 147 | +<div class="line"># Write the resampled image.</div> |
| 148 | +<div class="line">WriteImage(outputImage, "landmark_example.png")</div> |
| 149 | +<div class="line"> </div> |
| 150 | +<div class="line"># Write the transform.</div> |
| 151 | +<div class="line">if (length(args) > 0) {</div> |
| 152 | +<div class="line"> outName <- args[1]</div> |
| 153 | +<div class="line">} else {</div> |
| 154 | +<div class="line"> outName <- "landmark_transform.tfm"</div> |
| 155 | +<div class="line">}</div> |
| 156 | +<div class="line"> </div> |
| 157 | +<div class="line">WriteTransform(outputTransform, outName)</div> |
| 158 | +</div><!-- fragment --> </div><!-- contents --> |
| 159 | +<!-- HTML footer for doxygen 1.8.17--> |
| 160 | +<!-- start footer part --> |
| 161 | +<hr class="footer"/><address class="footer"><small> |
| 162 | + Generated on <span id="datetime">unknown</span> for SimpleITK by   |
| 163 | + <a href="http://www.doxygen.org/index.html"> |
| 164 | +<img class="footer" src="doxygen.png" alt="doxygen"/> |
| 165 | +</a> 1.13.2 | <a href="https://simpleitk.org/privacy_policy.html"> |
| 166 | + Privacy Policy</a> |
| 167 | +</small></address> |
| 168 | +</body> |
| 169 | +</html> |
0 commit comments