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

/matlab_tools/Converted/kvextintersec.m

http://github.com/aludnam/MATLAB
Objective C | 200 lines | 197 code | 3 blank | 0 comment | 56 complexity | e7255d91caf9a320f55c296bdfd9ab6a MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kvextintersec 'Extended Intersection'
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros vextintersec.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: i3 'Input Image #3', optional: 'first input image'
  8. % InputFile: i4 'Input Image #4', optional: 'second input image'
  9. % InputFile: i5 'Input Image #5', optional: 'first input image'
  10. % InputFile: i6 'Input Image #6', optional: 'second input image'
  11. % OutputFile: o 'Output Image ', required: 'resulting output image'
  12. %
  13. % Example: o = kvextintersec({i1, i2, i3, i4, i5, i6}, {'i1','';'i2','';'i3','';'i4','';'i5','';'i6','';'o',''})
  14. %
  15. % Khoros helpfile follows below:
  16. %
  17. % PROGRAM
  18. % vextintersec - Extended Intersection
  19. %
  20. % DESCRIPTION
  21. % .I vextintersec
  22. % will do the infimum of multiple (up to six) input images pixel by pixel.
  23. %
  24. % The input images must be of the same size and have the same
  25. % number of data bands. The input
  26. % images may be of the same or different data types. If the input
  27. % images are of different data types, then all input images will be
  28. % upcast to the highest input image data type. The output
  29. % image data type will be the same as that of the highest data type
  30. % of the input images.
  31. %
  32. %
  33. %
  34. % EXAMPLES
  35. % vextintersec -i1 ball.xv -i2 feath.xv -i3 moon.xv -i4 feath6.xv -o outimage.xv
  36. %
  37. % Will do the infimum of images "ball.xv", "feath.xv", "moon.xv" and "feath6.xv" with the resulting image written to "outimage.xv".
  38. %
  39. % "SEE ALSO"
  40. % vcast1(1)
  41. %
  42. % RESTRICTIONS
  43. % .I vextintersec
  44. % 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.
  45. %
  46. % REFERENCES
  47. %
  48. % COPYRIGHT
  49. % Copyright (C) 1993-1997 Junior Barrera, Roberto Lotufo. All rights reserved.
  50. %
  51. function varargout = kvextintersec(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,..] = kvextintersec(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={'i1', '__input';'i2', '__input';'i3', '__input';'i4', '__input';'i5', '__input';'i6', '__input';'o', '__output'};
  64. maxval={0,0,1,1,1,1,0};
  65. minval={0,0,1,1,1,1,0};
  66. istoggle=[0,0,1,1,1,1,0];
  67. was_set=istoggle * 0;
  68. paramtype={'InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','OutputFile'};
  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 'vextintersec" '],Inputs,narglist);