PageRenderTime 46ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/matlab_tools/Converted/kvcondskthick.m

http://github.com/aludnam/MATLAB
Objective C | 221 lines | 218 code | 3 blank | 0 comment | 56 complexity | 6d7033a7755a9f94ad76ecd4e6e12e1b MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kvcondskthick 'Conditional Exoskeleton by Thickening'
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros vcondskthick.pane file
  3. %
  4. % Parameters:
  5. % InputFile: i1 'Input Image #1', required: 'first input image'
  6. % InputFile: i2 'Input Image #2', required: 'second input image'
  7. % InputFile: str1 'Struct Element 1', required: 'Structuring Element'
  8. % InputFile: str2 'Struct Element 2', required: 'Structuring Element'
  9. % MultiChoice: r 'Struct El. Rotation Step', default: 1: 'Rotation step'
  10. % Choices are:
  11. % 1: '1 '
  12. % 2: '2 '
  13. % 3: '4 '
  14. % OutputFile: o 'Output Image ', required: 'resulting output image'
  15. %
  16. % Example: o = kvcondskthick({i1, i2, str1, str2}, {'i1','';'i2','';'str1','';'str2','';'r',1;'o',''})
  17. %
  18. % Khoros helpfile follows below:
  19. %
  20. % PROGRAM
  21. % vcondskthick - Conditional Exoskeleton by Thickening
  22. %
  23. % DESCRIPTION
  24. % .I vcondskthick
  25. % will do the conditional exoskeleton by thickening of an input image by a conditional image and a set of structuring elements.
  26. %
  27. % The two input images must be of the same size and have the same
  28. % number of data bands. The input
  29. % images may be of the same or different data types. If the input
  30. % images are of different data types, then all input images will be
  31. % upcast to the highest input image data type. The output
  32. % image data type will be the same as that of the highest data type
  33. % of the input images.
  34. %
  35. % Some useful pairs of structuring elements:
  36. %
  37. % 0 0 0 1 1 1
  38. % Conditional Segmentation 0 1 0 0 0 0
  39. % 1 1 1 0 0 0
  40. %
  41. % 0 0 0 1 0 0
  42. % Pseudo Convex Hull 0 1 1 1 0 0
  43. % 0 0 0 1 0 0
  44. %
  45. % 1 0 0 0 0 0
  46. % Convex Hull 1 0 0 0 1 0
  47. % 1 0 0 0 0 0
  48. %
  49. % 0 0 0 1 1 1
  50. % Homotopic Pruning 0 1 0 1 0 1
  51. % 0 0 0 1 1 1
  52. %
  53. %
  54. %
  55. % EXAMPLES
  56. % vcondskthick -i1 ball.xv -i2 feath.xv -str1 b272.str -str2 b273.str -r 1 -o outimage.xv
  57. %
  58. % Will do the conditional exoskeleton by thickening of image 1 "ball.xv" by the structuring set b272.str and b273.str using "feath.xv" as a conditional image, rotating the struct. els. 1 step after each iteration, with the resulting image written to "outimage.xv".
  59. %
  60. % "SEE ALSO"
  61. %
  62. % RESTRICTIONS
  63. % .I vcondskthick
  64. % can be defined for all data types supported by Khoros, but at the moment it has been implemented just for the bit and unsigned char types.
  65. % The structuring elements are subsets of the 3x3 matrix and the origin is always at the center of this matrix.
  66. %
  67. % REFERENCES
  68. %
  69. % COPYRIGHT
  70. % Copyright (C) 1993-1997 Junior Barrera, Roberto Lotufo. All rights reserved.
  71. %
  72. function varargout = kvcondskthick(varargin)
  73. if nargin ==0
  74. Inputs={};arglist={'',''};
  75. elseif nargin ==1
  76. Inputs=varargin{1};arglist={'',''};
  77. elseif nargin ==2
  78. Inputs=varargin{1}; arglist=varargin{2};
  79. else error('Usage: [out1,..] = kvcondskthick(Inputs,arglist).');
  80. end
  81. if size(arglist,2)~=2
  82. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  83. end
  84. narglist={'i1', '__input';'i2', '__input';'str1', '__input';'str2', '__input';'r', 1;'o', '__output'};
  85. maxval={0,0,0,0,0,0};
  86. minval={0,0,0,0,0,0};
  87. istoggle=[0,0,0,0,0,0];
  88. was_set=istoggle * 0;
  89. paramtype={'InputFile','InputFile','InputFile','InputFile','MultiChoice','OutputFile'};
  90. % identify the input arrays and assign them to the arguments as stated by the user
  91. if ~iscell(Inputs)
  92. Inputs = {Inputs};
  93. end
  94. NumReqOutputs=1; nextinput=1; nextoutput=1;
  95. for ii=1:size(arglist,1)
  96. wasmatched=0;
  97. for jj=1:size(narglist,1)
  98. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  99. wasmatched = 1;
  100. was_set(jj) = 1;
  101. if strcmp(narglist{jj,2}, '__input')
  102. if (nextinput > length(Inputs))
  103. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  104. end
  105. narglist{jj,2} = 'OK_in';
  106. nextinput = nextinput + 1;
  107. elseif strcmp(narglist{jj,2}, '__output')
  108. if (nextoutput > nargout)
  109. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  110. end
  111. if (isempty(arglist{ii,2}))
  112. narglist{jj,2} = 'OK_out';
  113. else
  114. narglist{jj,2} = arglist{ii,2};
  115. end
  116. nextoutput = nextoutput + 1;
  117. if (minval{jj} == 0)
  118. NumReqOutputs = NumReqOutputs - 1;
  119. end
  120. elseif isstr(arglist{ii,2})
  121. narglist{jj,2} = arglist{ii,2};
  122. else
  123. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  124. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  125. end
  126. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  127. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  128. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  129. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  130. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  131. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  132. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  133. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  134. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  135. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  136. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  137. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  138. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  139. end
  140. end
  141. end
  142. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  143. narglist{jj,2} = arglist{ii,2};
  144. end
  145. end
  146. end
  147. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  148. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  149. end
  150. end
  151. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  152. for jj=1:size(narglist,1)
  153. if strcmp(paramtype{jj}, 'Toggle')
  154. if (narglist{jj,2} ==0)
  155. narglist{jj,1} = '';
  156. end;
  157. narglist{jj,2} = '';
  158. end;
  159. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  160. narglist{jj,1} = '';
  161. narglist{jj,2} = '';
  162. end;
  163. if strcmp(narglist{jj,2}, '__input')
  164. if (minval{jj} == 0) % meaning this input is required
  165. if (nextinput > size(Inputs))
  166. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  167. else
  168. narglist{jj,2} = 'OK_in';
  169. nextinput = nextinput + 1;
  170. end
  171. else % this is an optional input
  172. if (nextinput <= length(Inputs))
  173. narglist{jj,2} = 'OK_in';
  174. nextinput = nextinput + 1;
  175. else
  176. narglist{jj,1} = '';
  177. narglist{jj,2} = '';
  178. end;
  179. end;
  180. else
  181. if strcmp(narglist{jj,2}, '__output')
  182. if (minval{jj} == 0) % this is a required output
  183. if (nextoutput > nargout & nargout > 1)
  184. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  185. else
  186. narglist{jj,2} = 'OK_out';
  187. nextoutput = nextoutput + 1;
  188. NumReqOutputs = NumReqOutputs-1;
  189. end
  190. else % this is an optional output
  191. if (nargout - nextoutput >= NumReqOutputs)
  192. narglist{jj,2} = 'OK_out';
  193. nextoutput = nextoutput + 1;
  194. else
  195. narglist{jj,1} = '';
  196. narglist{jj,2} = '';
  197. end;
  198. end
  199. end
  200. end
  201. end
  202. if nargout
  203. varargout = cell(1,nargout);
  204. else
  205. varargout = cell(1,1);
  206. end
  207. global KhorosRoot
  208. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  209. w=['"' KhorosRoot];
  210. else
  211. if ispc
  212. w='"C:\Program Files\dip\khorosBin\';
  213. else
  214. [s,w] = system('which cantata');
  215. w=['"' w(1:end-8)];
  216. end
  217. end
  218. [varargout{:}]=callKhoros([w 'vcondskthick" '],Inputs,narglist);