PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/matlab_tools/Converted/kre_burr.m

http://github.com/aludnam/MATLAB
Objective C | 200 lines | 197 code | 3 blank | 0 comment | 55 complexity | 994c7c205fe3987d8ab8979eb9e3a49a MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kre_burr 'Burr elastic image registration'
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros re_burr.pane file
  3. %
  4. % Parameters:
  5. % InputFile: iref 'Reference Input ', required: 'reference image input'
  6. % InputFile: idist 'Distorted Input', required: 'distorted image input'
  7. % OutputFile: o 'Output', required: 'output image'
  8. % Integer: fdv_size 'FDV Size', default: 13: 'size of FDV search window'
  9. % Integer: said_size 'SAID Size', default: 7: 'size of SAID window'
  10. % Integer: coop_size 'Co-op Size', default: 5: 'size of cooperative neighborhood window'
  11. %
  12. % Example: o = kre_burr({iref, idist}, {'iref','';'idist','';'o','';'fdv_size',13;'said_size',7;'coop_size',5})
  13. %
  14. % Khoros helpfile follows below:
  15. %
  16. % PROGRAM
  17. % re_burr - Burr elastic image registration
  18. %
  19. % DESCRIPTION
  20. % This routine performs one iteration of the Burr
  21. % elastic image registration method. The algorithm
  22. % begins by computing a feature displacement vector
  23. % (FDV) for each pixel in both the ref and dist images.
  24. % The size of the FDV window limits the maximum
  25. % displacement of any given pixel. The SAID
  26. % correlation measure is used to determine the
  27. % similarity between pixels. The SAID window size
  28. % determines the window over which the terms of this
  29. % correlation are summed. Finally, the 'pushing' and
  30. % 'pulling' FDV's are combined to determine the actual
  31. % displacement of the pixel. Only FDV's with in the
  32. % cooperative neighborhood window are employed in
  33. % finding this final displacement.
  34. %
  35. %
  36. %
  37. % EXAMPLES
  38. % See the html tutorial in $REGISTER/examples/html/README_FIRST.html
  39. %
  40. % "SEE ALSO"
  41. %
  42. % RESTRICTIONS
  43. %
  44. % REFERENCES
  45. % Burr, D.J. "A Dynamic Model for Image Registration"
  46. % COMPUTER GRAPHICS AND IMAGE PROCESSING. vol. 15, pp 102-12. 1981.
  47. %
  48. % COPYRIGHT
  49. % Copyright (C) 1996 - 1997, University of New Mexico. All rights reserved.
  50. %
  51. function varargout = kre_burr(varargin)
  52. if nargin ==0
  53. Inputs={};arglist={'',''};
  54. elseif nargin ==1
  55. Inputs=varargin{1};arglist={'',''};
  56. elseif nargin ==2
  57. Inputs=varargin{1}; arglist=varargin{2};
  58. else error('Usage: [out1,..] = kre_burr(Inputs,arglist).');
  59. end
  60. if size(arglist,2)~=2
  61. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  62. end
  63. narglist={'iref', '__input';'idist', '__input';'o', '__output';'fdv_size', 13;'said_size', 7;'coop_size', 5};
  64. maxval={0,0,0,2,2,2};
  65. minval={0,0,0,2,2,2};
  66. istoggle=[0,0,0,0,0,0];
  67. was_set=istoggle * 0;
  68. paramtype={'InputFile','InputFile','OutputFile','Integer','Integer','Integer'};
  69. % identify the input arrays and assign them to the arguments as stated by the user
  70. if ~iscell(Inputs)
  71. Inputs = {Inputs};
  72. end
  73. NumReqOutputs=1; nextinput=1; nextoutput=1;
  74. for ii=1:size(arglist,1)
  75. wasmatched=0;
  76. for jj=1:size(narglist,1)
  77. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  78. wasmatched = 1;
  79. was_set(jj) = 1;
  80. if strcmp(narglist{jj,2}, '__input')
  81. if (nextinput > length(Inputs))
  82. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  83. end
  84. narglist{jj,2} = 'OK_in';
  85. nextinput = nextinput + 1;
  86. elseif strcmp(narglist{jj,2}, '__output')
  87. if (nextoutput > nargout)
  88. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  89. end
  90. if (isempty(arglist{ii,2}))
  91. narglist{jj,2} = 'OK_out';
  92. else
  93. narglist{jj,2} = arglist{ii,2};
  94. end
  95. nextoutput = nextoutput + 1;
  96. if (minval{jj} == 0)
  97. NumReqOutputs = NumReqOutputs - 1;
  98. end
  99. elseif isstr(arglist{ii,2})
  100. narglist{jj,2} = arglist{ii,2};
  101. else
  102. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  103. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  104. end
  105. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  106. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  107. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  108. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  109. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  110. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  111. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  112. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  113. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  114. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  115. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  116. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  117. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  118. end
  119. end
  120. end
  121. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  122. narglist{jj,2} = arglist{ii,2};
  123. end
  124. end
  125. end
  126. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  127. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  128. end
  129. end
  130. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  131. for jj=1:size(narglist,1)
  132. if strcmp(paramtype{jj}, 'Toggle')
  133. if (narglist{jj,2} ==0)
  134. narglist{jj,1} = '';
  135. end;
  136. narglist{jj,2} = '';
  137. end;
  138. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  139. narglist{jj,1} = '';
  140. narglist{jj,2} = '';
  141. end;
  142. if strcmp(narglist{jj,2}, '__input')
  143. if (minval{jj} == 0) % meaning this input is required
  144. if (nextinput > size(Inputs))
  145. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  146. else
  147. narglist{jj,2} = 'OK_in';
  148. nextinput = nextinput + 1;
  149. end
  150. else % this is an optional input
  151. if (nextinput <= length(Inputs))
  152. narglist{jj,2} = 'OK_in';
  153. nextinput = nextinput + 1;
  154. else
  155. narglist{jj,1} = '';
  156. narglist{jj,2} = '';
  157. end;
  158. end;
  159. else
  160. if strcmp(narglist{jj,2}, '__output')
  161. if (minval{jj} == 0) % this is a required output
  162. if (nextoutput > nargout & nargout > 1)
  163. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  164. else
  165. narglist{jj,2} = 'OK_out';
  166. nextoutput = nextoutput + 1;
  167. NumReqOutputs = NumReqOutputs-1;
  168. end
  169. else % this is an optional output
  170. if (nargout - nextoutput >= NumReqOutputs)
  171. narglist{jj,2} = 'OK_out';
  172. nextoutput = nextoutput + 1;
  173. else
  174. narglist{jj,1} = '';
  175. narglist{jj,2} = '';
  176. end;
  177. end
  178. end
  179. end
  180. end
  181. if nargout
  182. varargout = cell(1,nargout);
  183. else
  184. varargout = cell(1,1);
  185. end
  186. global KhorosRoot
  187. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  188. w=['"' KhorosRoot];
  189. else
  190. if ispc
  191. w='"C:\Program Files\dip\khorosBin\';
  192. else
  193. [s,w] = system('which cantata');
  194. w=['"' w(1:end-8)];
  195. end
  196. end
  197. [varargout{:}]=callKhoros([w 're_burr" '],Inputs,narglist);