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

/matlab_tools/Converted/kkabitmap.m

http://github.com/aludnam/MATLAB
Objective C | 194 lines | 191 code | 3 blank | 0 comment | 60 complexity | 8657188d1d3f5af9f21da68dfc61664a MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kkabitmap 'Add a bitmap annotation object to a kobject '
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros kabitmap.pane file
  3. %
  4. % Parameters:
  5. % InputFile: i 'Input ', required: 'First Input data object'
  6. % InputFile: ib 'Input bitmap', required: 'Second Input data object (kobject for bitmap creation)'
  7. % String: x 'X Position', default: '0': 'upper coordinate of bitmap placement'
  8. % String: y 'Y Position', default: '0': 'left coordinate of bitmap placement'
  9. % String: d 'Depth Position', default: '*': 'depth coordinate of bitmap placement'
  10. % String: t 'Time Position', default: '*': 'time coordinate of bitmap placement'
  11. % Integer: opacity 'Opacity', default: 100: 'Opacity for the bitmap'
  12. % String: transparent 'Additional transparent colors', default: ' ': 'list of additional transparent colors (separated by ;)'
  13. % OutputFile: o 'Output', required: 'Resulting output data object'
  14. %
  15. % Example: o = kkabitmap({i, ib}, {'i','';'ib','';'x','0';'y','0';'d','*';'t','*';'opacity',100;'transparent',' ';'o',''})
  16. %
  17. % Khoros helpfile follows below:
  18. %
  19. % PROGRAM
  20. % kabitmap - Add a bitmap annotation object to a kobject
  21. %
  22. % DESCRIPTION
  23. % This operator adds a bitmap annotation object to a kobject (specified with the [-i] parameter), saving the object with the new annotation in the file specified with the [-o] parameter. All embedded objects in the input object will be copied to the output object, which data will not be modified until it is passed through the karender kroutine. The bitmap is created from an image specified with the [-ib] parameter, which must be actually a kobject.
  24. % The position of the bitmap object is specified with the [-x] (start column) and [-y] (start row) coordinates. The bitmap will appear only on the frames specified with the [-t] and [-d] parameters.
  25. % The opacity that will be used when the object is rendered is specified with the [-opacity] parameter.
  26. % If there is mask on the input bitmap ([-ib]), the masked pixels will be considered completely transparent when rendered by karender. Some specific colors in the bitmap can be also be considered as transparent, and can be specified using the [-transparent] parameter, which is a list of strings separated by the ; character.
  27. %
  28. %
  29. %
  30. % EXAMPLES
  31. % All examples for the Annotate toolbox are listed on the $ANNOTATE/manual/index.html on-line manual.
  32. %
  33. % "SEE ALSO"
  34. % karender, kman pages for ka_decode_coord and ka_decode_frame_coord and on-line manual for information on the coordinates specification schemes.
  35. %
  36. % RESTRICTIONS
  37. % Expect the input bitmap file [-ib] to contain a single-frame image with e = 1 or 3.
  38. %
  39. % REFERENCES
  40. % All references for the Annotate toolbox are listed on the $ANNOTATE/manual/index.html on-line manual.
  41. %
  42. % COPYRIGHT
  43. % Annotate Toolbox v1.0 Copyright (C) 1997, Rafael Santos.
  44. %
  45. function varargout = kkabitmap(varargin)
  46. if nargin ==0
  47. Inputs={};arglist={'',''};
  48. elseif nargin ==1
  49. Inputs=varargin{1};arglist={'',''};
  50. elseif nargin ==2
  51. Inputs=varargin{1}; arglist=varargin{2};
  52. else error('Usage: [out1,..] = kkabitmap(Inputs,arglist).');
  53. end
  54. if size(arglist,2)~=2
  55. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  56. end
  57. narglist={'i', '__input';'ib', '__input';'x', '0';'y', '0';'d', '*';'t', '*';'opacity', 100;'transparent', ' ';'o', '__output'};
  58. maxval={0,0,0,0,0,0,100,0,0};
  59. minval={0,0,0,0,0,0,0,0,0};
  60. istoggle=[0,0,0,0,1,1,1,1,0];
  61. was_set=istoggle * 0;
  62. paramtype={'InputFile','InputFile','String','String','String','String','Integer','String','OutputFile'};
  63. % identify the input arrays and assign them to the arguments as stated by the user
  64. if ~iscell(Inputs)
  65. Inputs = {Inputs};
  66. end
  67. NumReqOutputs=1; nextinput=1; nextoutput=1;
  68. for ii=1:size(arglist,1)
  69. wasmatched=0;
  70. for jj=1:size(narglist,1)
  71. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  72. wasmatched = 1;
  73. was_set(jj) = 1;
  74. if strcmp(narglist{jj,2}, '__input')
  75. if (nextinput > length(Inputs))
  76. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  77. end
  78. narglist{jj,2} = 'OK_in';
  79. nextinput = nextinput + 1;
  80. elseif strcmp(narglist{jj,2}, '__output')
  81. if (nextoutput > nargout)
  82. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  83. end
  84. if (isempty(arglist{ii,2}))
  85. narglist{jj,2} = 'OK_out';
  86. else
  87. narglist{jj,2} = arglist{ii,2};
  88. end
  89. nextoutput = nextoutput + 1;
  90. if (minval{jj} == 0)
  91. NumReqOutputs = NumReqOutputs - 1;
  92. end
  93. elseif isstr(arglist{ii,2})
  94. narglist{jj,2} = arglist{ii,2};
  95. else
  96. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  97. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  98. end
  99. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  100. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  101. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  102. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  103. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  104. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  105. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  106. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  107. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  108. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  109. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  110. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  111. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  112. end
  113. end
  114. end
  115. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  116. narglist{jj,2} = arglist{ii,2};
  117. end
  118. end
  119. end
  120. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  121. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  122. end
  123. end
  124. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  125. for jj=1:size(narglist,1)
  126. if strcmp(paramtype{jj}, 'Toggle')
  127. if (narglist{jj,2} ==0)
  128. narglist{jj,1} = '';
  129. end;
  130. narglist{jj,2} = '';
  131. end;
  132. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  133. narglist{jj,1} = '';
  134. narglist{jj,2} = '';
  135. end;
  136. if strcmp(narglist{jj,2}, '__input')
  137. if (minval{jj} == 0) % meaning this input is required
  138. if (nextinput > size(Inputs))
  139. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  140. else
  141. narglist{jj,2} = 'OK_in';
  142. nextinput = nextinput + 1;
  143. end
  144. else % this is an optional input
  145. if (nextinput <= length(Inputs))
  146. narglist{jj,2} = 'OK_in';
  147. nextinput = nextinput + 1;
  148. else
  149. narglist{jj,1} = '';
  150. narglist{jj,2} = '';
  151. end;
  152. end;
  153. else
  154. if strcmp(narglist{jj,2}, '__output')
  155. if (minval{jj} == 0) % this is a required output
  156. if (nextoutput > nargout & nargout > 1)
  157. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  158. else
  159. narglist{jj,2} = 'OK_out';
  160. nextoutput = nextoutput + 1;
  161. NumReqOutputs = NumReqOutputs-1;
  162. end
  163. else % this is an optional output
  164. if (nargout - nextoutput >= NumReqOutputs)
  165. narglist{jj,2} = 'OK_out';
  166. nextoutput = nextoutput + 1;
  167. else
  168. narglist{jj,1} = '';
  169. narglist{jj,2} = '';
  170. end;
  171. end
  172. end
  173. end
  174. end
  175. if nargout
  176. varargout = cell(1,nargout);
  177. else
  178. varargout = cell(1,1);
  179. end
  180. global KhorosRoot
  181. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  182. w=['"' KhorosRoot];
  183. else
  184. if ispc
  185. w='"C:\Program Files\dip\khorosBin\';
  186. else
  187. [s,w] = system('which cantata');
  188. w=['"' w(1:end-8)];
  189. end
  190. end
  191. [varargout{:}]=callKhoros([w 'kabitmap" '],Inputs,narglist);