PageRenderTime 37ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/matlab_tools/Converted/kputzoom.m

http://github.com/aludnam/MATLAB
Objective C | 260 lines | 257 code | 3 blank | 0 comment | 62 complexity | 2999af0287ec8119c149c6ce32f23a83 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kputzoom 'Non-Interactive Display of a Zoom Image'
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros putzoom.pane file
  3. %
  4. % Parameters:
  5. % InputFile: i 'Input File', required: 'File containing image on which to zoom'
  6. % InputFile: cmap 'Input Colormap ', optional: 'File containing alternate colormap filename'
  7. % InputFile: clip 'Input Clip Mask', optional: 'File containing clip mask'
  8. % Integer: zoomx 'X Position ', default: 0: 'Specifies the x position where the zoom window is focused'
  9. % Integer: zoomy 'Y Position ', default: 0: 'Specifies the y position where the zoom window is focused'
  10. % Integer: x 'X Placement', default: -1: 'X location for GUI autoplacement'
  11. % Integer: width 'Window Width ', default: 256: 'Window width'
  12. % Integer: y 'Y Placement', default: -1: 'Y location for GUI autoplacement'
  13. % Integer: height 'Window Height', default: 256: 'Window height'
  14. % Double: update 'Update time', default: 2: 'How often to check input file for modification'
  15. %
  16. % Example: kputzoom({i, cmap, clip}, {'i','';'cmap','';'clip','';'zoomx',0;'zoomy',0;'x',-1;'width',256;'y',-1;'height',256;'update',2})
  17. %
  18. % Khoros helpfile follows below:
  19. %
  20. % PROGRAM
  21. % putzoom - Non-Interactive Display of a Zoom Image
  22. %
  23. % DESCRIPTION
  24. % Putzoom is a visualization program that displays a "zoomed" image, or
  25. % a close-up of a region of interest in an image.
  26. %
  27. % The input file containing the data to be displayed as a zoom is
  28. % monitored by default; the file is checked every 2 seconds for change,
  29. % and if it has been modified, the zoom display is updated accordingly.
  30. % The interval at which the input file is checked for modification may
  31. % be specified using the [-update] argument.
  32. %
  33. % A clip mask may be used to dictate the portion of the data that is
  34. % displayed using the [-clip] argument. For more information of using
  35. % clip masks, see Chapter 4 on Editimage.
  36. %
  37. % An alternate input color map may be used to change the current color map
  38. % using the [-cmap] argument.
  39. %
  40. % The x and y coordinates that specify where the zoomed image focuses
  41. % within the source image can be expressed using the [-zoomx] and
  42. % [-zoomy] arguments.
  43. %
  44. % It is possible to specify the zoom factor using the [-zoomfactor]
  45. % argument. When the zoom factor takes on values greater than one, the
  46. % object is "zoomed in" and when the zoom factor takes on values less
  47. % than one, the object is "zoomed out". For example, a value of 2.0 doubles the
  48. % size of the image, while a value of 0.5 shrinks the image by half. The zoom
  49. % factor is intentionally a double precision value; this means that in the case
  50. % of pixel replication, pixels are rounded to their nearest location. This also
  51. % implies that under certain circumstances, the zoom will not appear to stretch
  52. % evenly over the entire image.
  53. %
  54. % By default, the visualization display will share its colormap with all
  55. % other applications running at the same time; that is, it does not not
  56. % use a private colormap, but rather makes use of the default
  57. % colormap. It is possible to specify that the visualization display
  58. % allocate its own private colormap or "grab" all available colors for
  59. % its own use. This is done using the [-priv] argument. When [-priv]
  60. % is specified, moving the mouse pointer into the display window will
  61. % cause the display to have its private colormap installed; moving the
  62. % pointer out of the display window will cause the private colormap to
  63. % be de-installed. This results in the "technoflashing" phenomenon
  64. % characteristic of colormap switching.
  65. %
  66. % Color allocation can also be controlled and set to either
  67. % .I "read-only"
  68. % or
  69. % .I "read/write"
  70. % using the [-alloc] argument. When set to
  71. % .I "read-only",
  72. % once a color cell has been allocated, it can have its color set only once;
  73. % from then on, the color cell can be shared by multiple applications, but
  74. % not changed. If the visualization display requires the color displayed
  75. % to change, it must re-allocate the color cell, forcing a re-display of
  76. % data. This can be an expensive procedure. In contrast, after a
  77. % .I "read/write"
  78. % color cell is allocated, it can have its color changed at any time
  79. % without re-allocation; the data being displayed does not need to be
  80. % redisplayed, and the color update process is much more efficient.
  81. % However, the colors used in the visualization display cannot be shared by
  82. % other applications.
  83. %
  84. % On creation, the zoom display window may be placed manually (the
  85. % default method), or placed automatically. For automatic placement
  86. % of the zoom window, specify the desired location in device (screen)
  87. % coordinates using the [-x] and [-y] arguments.
  88. %
  89. % While the zoom display window should be created with a default size
  90. % that is appropriate to display the data, a width and height for the
  91. % window can be specified explicitly using the [-width] and [-height]
  92. % arguments. Note that interactive resizing of the image display
  93. % window using the window manager is currently NOT supported.
  94. %
  95. %
  96. %
  97. % EXAMPLES
  98. % % putzoom -i image:mandril
  99. % % putzoom -i image:moon
  100. %
  101. % "SEE ALSO"
  102. % putdata(1)
  103. %
  104. % RESTRICTIONS
  105. %
  106. % REFERENCES
  107. %
  108. % COPYRIGHT
  109. % Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.
  110. %
  111. function varargout = kputzoom(varargin)
  112. if nargin ==0
  113. Inputs={};arglist={'',''};
  114. elseif nargin ==1
  115. Inputs=varargin{1};arglist={'',''};
  116. elseif nargin ==2
  117. Inputs=varargin{1}; arglist=varargin{2};
  118. else error('Usage: [out1,..] = kputzoom(Inputs,arglist).');
  119. end
  120. if size(arglist,2)~=2
  121. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  122. end
  123. narglist={'i', '__input';'cmap', '__input';'clip', '__input';'zoomx', 0;'zoomy', 0;'x', -1;'width', 256;'y', -1;'height', 256;'update', 2};
  124. maxval={0,1,1,1,1,1000,1000,1000,1000,1};
  125. minval={0,1,1,1,1,-1,-1,-1,-1,1};
  126. istoggle=[0,1,1,1,1,1,1,1,1,1];
  127. was_set=istoggle * 0;
  128. paramtype={'InputFile','InputFile','InputFile','Integer','Integer','Integer','Integer','Integer','Integer','Double'};
  129. % identify the input arrays and assign them to the arguments as stated by the user
  130. if ~iscell(Inputs)
  131. Inputs = {Inputs};
  132. end
  133. NumReqOutputs=0; nextinput=1; nextoutput=1;
  134. for ii=1:size(arglist,1)
  135. wasmatched=0;
  136. for jj=1:size(narglist,1)
  137. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  138. wasmatched = 1;
  139. was_set(jj) = 1;
  140. if strcmp(narglist{jj,2}, '__input')
  141. if (nextinput > length(Inputs))
  142. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  143. end
  144. narglist{jj,2} = 'OK_in';
  145. nextinput = nextinput + 1;
  146. elseif strcmp(narglist{jj,2}, '__output')
  147. if (nextoutput > nargout)
  148. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  149. end
  150. if (isempty(arglist{ii,2}))
  151. narglist{jj,2} = 'OK_out';
  152. else
  153. narglist{jj,2} = arglist{ii,2};
  154. end
  155. nextoutput = nextoutput + 1;
  156. if (minval{jj} == 0)
  157. NumReqOutputs = NumReqOutputs - 1;
  158. end
  159. elseif isstr(arglist{ii,2})
  160. narglist{jj,2} = arglist{ii,2};
  161. else
  162. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  163. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  164. end
  165. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  166. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  167. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  168. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  169. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  170. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  171. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  172. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  173. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  174. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  175. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  176. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  177. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  178. end
  179. end
  180. end
  181. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  182. narglist{jj,2} = arglist{ii,2};
  183. end
  184. end
  185. end
  186. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  187. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  188. end
  189. end
  190. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  191. for jj=1:size(narglist,1)
  192. if strcmp(paramtype{jj}, 'Toggle')
  193. if (narglist{jj,2} ==0)
  194. narglist{jj,1} = '';
  195. end;
  196. narglist{jj,2} = '';
  197. end;
  198. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  199. narglist{jj,1} = '';
  200. narglist{jj,2} = '';
  201. end;
  202. if strcmp(narglist{jj,2}, '__input')
  203. if (minval{jj} == 0) % meaning this input is required
  204. if (nextinput > size(Inputs))
  205. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  206. else
  207. narglist{jj,2} = 'OK_in';
  208. nextinput = nextinput + 1;
  209. end
  210. else % this is an optional input
  211. if (nextinput <= length(Inputs))
  212. narglist{jj,2} = 'OK_in';
  213. nextinput = nextinput + 1;
  214. else
  215. narglist{jj,1} = '';
  216. narglist{jj,2} = '';
  217. end;
  218. end;
  219. else
  220. if strcmp(narglist{jj,2}, '__output')
  221. if (minval{jj} == 0) % this is a required output
  222. if (nextoutput > nargout & nargout > 1)
  223. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  224. else
  225. narglist{jj,2} = 'OK_out';
  226. nextoutput = nextoutput + 1;
  227. NumReqOutputs = NumReqOutputs-1;
  228. end
  229. else % this is an optional output
  230. if (nargout - nextoutput >= NumReqOutputs)
  231. narglist{jj,2} = 'OK_out';
  232. nextoutput = nextoutput + 1;
  233. else
  234. narglist{jj,1} = '';
  235. narglist{jj,2} = '';
  236. end;
  237. end
  238. end
  239. end
  240. end
  241. if nargout
  242. varargout = cell(1,nargout);
  243. else
  244. varargout = cell(0);
  245. end
  246. global KhorosRoot
  247. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  248. w=['"' KhorosRoot];
  249. else
  250. if ispc
  251. w='"C:\Program Files\dip\khorosBin\';
  252. else
  253. [s,w] = system('which cantata');
  254. w=['"' w(1:end-8)];
  255. end
  256. end
  257. callKhoros([w 'putdata" -zoom'],Inputs,narglist);