PageRenderTime 47ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/matlab_tools/Converted/kvchghomot.m

http://github.com/aludnam/MATLAB
Objective C | 191 lines | 188 code | 3 blank | 0 comment | 56 complexity | 246c83902be46d38a6b526a7b4e07bd8 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kvchghomot 'Minima Imposition'
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros vchghomot.pane file
  3. %
  4. % Parameters:
  5. % InputFile: i1 'Input Image', required: 'Image to be transformed'
  6. % InputFile: i2 'Marker', required: 'Image with reference points'
  7. % InputFile: str 'Struct Element', required: 'Structuring Element which defines the connectivity used '
  8. % OutputFile: o 'Output Image', required: 'resulting output image'
  9. %
  10. % Example: o = kvchghomot({i1, i2, str}, {'i1','';'i2','';'str','';'o',''})
  11. %
  12. % Khoros helpfile follows below:
  13. %
  14. % PROGRAM
  15. % vchghomot - Minima Imposition
  16. %
  17. % DESCRIPTION
  18. % .I vchghomot
  19. % will change the homotopy of an image, based on a reference image.
  20. %
  21. %
  22. %
  23. %
  24. %
  25. % EXAMPLES
  26. % vchghomot -i1 feath.xv -str b.str -o outimage.xv
  27. %
  28. % Will change the homotopy of the input image "feath.xv". The connectivity is defined by the structuring element b. The transformed image is written to "outimage.xv".
  29. %
  30. % "SEE ALSO"
  31. % vcast1(1)
  32. %
  33. % RESTRICTIONS
  34. % .I vchghomot
  35. % can be defined for all data types supported by Khoros (except bit), but at the moment it has been implemented just for the unsigned char type.
  36. %
  37. % REFERENCES
  38. %
  39. % COPYRIGHT
  40. % Copyright (C) 1993-1997 Junior Barrera, Roberto Lotufo. All rights reserved.
  41. %
  42. function varargout = kvchghomot(varargin)
  43. if nargin ==0
  44. Inputs={};arglist={'',''};
  45. elseif nargin ==1
  46. Inputs=varargin{1};arglist={'',''};
  47. elseif nargin ==2
  48. Inputs=varargin{1}; arglist=varargin{2};
  49. else error('Usage: [out1,..] = kvchghomot(Inputs,arglist).');
  50. end
  51. if size(arglist,2)~=2
  52. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  53. end
  54. narglist={'i1', '__input';'i2', '__input';'str', '__input';'o', '__output'};
  55. maxval={0,0,0,0};
  56. minval={0,0,0,0};
  57. istoggle=[0,0,0,0];
  58. was_set=istoggle * 0;
  59. paramtype={'InputFile','InputFile','InputFile','OutputFile'};
  60. % identify the input arrays and assign them to the arguments as stated by the user
  61. if ~iscell(Inputs)
  62. Inputs = {Inputs};
  63. end
  64. NumReqOutputs=1; nextinput=1; nextoutput=1;
  65. for ii=1:size(arglist,1)
  66. wasmatched=0;
  67. for jj=1:size(narglist,1)
  68. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  69. wasmatched = 1;
  70. was_set(jj) = 1;
  71. if strcmp(narglist{jj,2}, '__input')
  72. if (nextinput > length(Inputs))
  73. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  74. end
  75. narglist{jj,2} = 'OK_in';
  76. nextinput = nextinput + 1;
  77. elseif strcmp(narglist{jj,2}, '__output')
  78. if (nextoutput > nargout)
  79. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  80. end
  81. if (isempty(arglist{ii,2}))
  82. narglist{jj,2} = 'OK_out';
  83. else
  84. narglist{jj,2} = arglist{ii,2};
  85. end
  86. nextoutput = nextoutput + 1;
  87. if (minval{jj} == 0)
  88. NumReqOutputs = NumReqOutputs - 1;
  89. end
  90. elseif isstr(arglist{ii,2})
  91. narglist{jj,2} = arglist{ii,2};
  92. else
  93. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  94. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  95. end
  96. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  97. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  98. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  99. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  100. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  101. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  102. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  103. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  104. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  105. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  106. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  107. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  108. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  109. end
  110. end
  111. end
  112. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  113. narglist{jj,2} = arglist{ii,2};
  114. end
  115. end
  116. end
  117. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  118. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  119. end
  120. end
  121. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  122. for jj=1:size(narglist,1)
  123. if strcmp(paramtype{jj}, 'Toggle')
  124. if (narglist{jj,2} ==0)
  125. narglist{jj,1} = '';
  126. end;
  127. narglist{jj,2} = '';
  128. end;
  129. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  130. narglist{jj,1} = '';
  131. narglist{jj,2} = '';
  132. end;
  133. if strcmp(narglist{jj,2}, '__input')
  134. if (minval{jj} == 0) % meaning this input is required
  135. if (nextinput > size(Inputs))
  136. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  137. else
  138. narglist{jj,2} = 'OK_in';
  139. nextinput = nextinput + 1;
  140. end
  141. else % this is an optional input
  142. if (nextinput <= length(Inputs))
  143. narglist{jj,2} = 'OK_in';
  144. nextinput = nextinput + 1;
  145. else
  146. narglist{jj,1} = '';
  147. narglist{jj,2} = '';
  148. end;
  149. end;
  150. else
  151. if strcmp(narglist{jj,2}, '__output')
  152. if (minval{jj} == 0) % this is a required output
  153. if (nextoutput > nargout & nargout > 1)
  154. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  155. else
  156. narglist{jj,2} = 'OK_out';
  157. nextoutput = nextoutput + 1;
  158. NumReqOutputs = NumReqOutputs-1;
  159. end
  160. else % this is an optional output
  161. if (nargout - nextoutput >= NumReqOutputs)
  162. narglist{jj,2} = 'OK_out';
  163. nextoutput = nextoutput + 1;
  164. else
  165. narglist{jj,1} = '';
  166. narglist{jj,2} = '';
  167. end;
  168. end
  169. end
  170. end
  171. end
  172. if nargout
  173. varargout = cell(1,nargout);
  174. else
  175. varargout = cell(1,1);
  176. end
  177. global KhorosRoot
  178. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  179. w=['"' KhorosRoot];
  180. else
  181. if ispc
  182. w='"C:\Program Files\dip\khorosBin\';
  183. else
  184. [s,w] = system('which cantata');
  185. w=['"' w(1:end-8)];
  186. end
  187. end
  188. [varargout{:}]=callKhoros([w 'vchghomot" '],Inputs,narglist);