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

/matlab_tools/Converted/keditimage.m

http://github.com/aludnam/MATLAB
Objective C | 240 lines | 237 code | 3 blank | 0 comment | 57 complexity | 5c1363a702afcd750703cd85f49b7ce7 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %keditimage 'Interactive Image Display and Manipulation'
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros editimage.pane file
  3. %
  4. % Parameters:
  5. % InputFile: i 'Input File', optional: 'File containing image'
  6. % InputFile: cmap 'Input Colormap ', optional: 'File containing alternate colormap file'
  7. % InputFile: clip 'Input Clip Gate', optional: 'File containing clip mask'
  8. % Integer: x 'X placement', default: -1: 'X location for GUI autoplacement'
  9. % Integer: y 'Y placement', default: -1: 'Y location for GUI autoplacement'
  10. % Double: update 'Update time', default: 1: 'How often to check input file for modification'
  11. %
  12. % Example: keditimage({i, cmap, clip}, {'i','';'cmap','';'clip','';'x',-1;'y',-1;'update',1})
  13. %
  14. % Khoros helpfile follows below:
  15. %
  16. % PROGRAM
  17. % editimage - Interactive Image Display and Manipulation
  18. %
  19. % DESCRIPTION
  20. % "Editimage" is an interactive image display and manipulation tool.
  21. % The features provided by "editimage" include:
  22. % - Transparent support of a variety of input files
  23. % - Use of clip masks
  24. % - Capture of images from the screen
  25. % - An input file history list
  26. % - For multiband images, control over which band is displayed
  27. % - Normalization of colormaps
  28. % - Control over which columns of the map data are displayed as red, green, and blue
  29. % - Application of functions to the map data values to produce new colormaps
  30. % - Interactive editing of the image file comment
  31. % - Application of autocolor procedures and colormap operations
  32. % - Regular and irregular region of interest extraction
  33. % - Creation of new data sets as defined by an interactively specified function
  34. % - Zooming on the displayed image
  35. % - Display of pixel values surrounding the location of the pointer in the image
  36. % - Display of map data values surrounding the location of the pointer in the image
  37. % - Colormap manipulation via a pseudo-coloring mechanism
  38. % - Pixel clipping and pixel thresholding on the image
  39. %
  40. % The master form of "editimage" displays the input image in a workspace.
  41. % Above the workspace are "License", "Help", and "Quit" buttons, from which one
  42. % may access the license agreement, display online help pages, and quit the
  43. % program, respectively. To the left of the image workspace are two subform
  44. % buttons labeled "Files" and "Options".
  45. %
  46. % Use the "Files" subform button to display the "Input and Output Files" subform.
  47. % From this subform, you may input and output files.
  48. %
  49. % A number of features are available from the "Options" subform, which
  50. % contains seven panes: "Capture", "Image List", "Display", "Comment",
  51. % "Colormaps", "Extract ROI", and "Function".
  52. %
  53. % Beneath the "Options" subform button are five more subform buttons, each
  54. % of which will display the relevant subform.
  55. %
  56. % The "Zoom" subform lets you zoom in on the image.
  57. %
  58. % The "Pixel Values" subform prints pixel values as the pointer is moved
  59. % across the image.
  60. %
  61. % The "Map Values" subform prints map data values as the pointer is moved
  62. % across the image.
  63. %
  64. % The "Pseudo Color" subform allows you to interactively modify the
  65. % colormap of the image.
  66. %
  67. % The "Threshold" subform supports pixel clipping and thresholding on the
  68. % image.
  69. %
  70. %
  71. %
  72. % EXAMPLES
  73. % % editimage -i image:moon
  74. %
  75. % "SEE ALSO"
  76. % animate(1), editcmap(1)
  77. % Editimage is covered in Chapter 4 of the Envision Toolbox Manual.
  78. %
  79. % RESTRICTIONS
  80. % Currently, the following features are not yet supported:
  81. % - Overlay of Images
  82. % - Use of different colorspaces (CMY, HLS, etc) with the pseudocoloring feature.
  83. %
  84. % REFERENCES
  85. % Editimage is documented in much greater detail in Chapter 4, "Editimage",
  86. % of the Envision Toolbox Manual.
  87. %
  88. % COPYRIGHT
  89. % Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.
  90. %
  91. function varargout = keditimage(varargin)
  92. if nargin ==0
  93. Inputs={};arglist={'',''};
  94. elseif nargin ==1
  95. Inputs=varargin{1};arglist={'',''};
  96. elseif nargin ==2
  97. Inputs=varargin{1}; arglist=varargin{2};
  98. else error('Usage: [out1,..] = keditimage(Inputs,arglist).');
  99. end
  100. if size(arglist,2)~=2
  101. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  102. end
  103. narglist={'i', '__input';'cmap', '__input';'clip', '__input';'x', -1;'y', -1;'update', 1};
  104. maxval={1,1,1,1000,1000,1};
  105. minval={1,1,1,-1,-1,1};
  106. istoggle=[1,1,1,1,1,1];
  107. was_set=istoggle * 0;
  108. paramtype={'InputFile','InputFile','InputFile','Integer','Integer','Double'};
  109. % identify the input arrays and assign them to the arguments as stated by the user
  110. if ~iscell(Inputs)
  111. Inputs = {Inputs};
  112. end
  113. NumReqOutputs=0; nextinput=1; nextoutput=1;
  114. for ii=1:size(arglist,1)
  115. wasmatched=0;
  116. for jj=1:size(narglist,1)
  117. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  118. wasmatched = 1;
  119. was_set(jj) = 1;
  120. if strcmp(narglist{jj,2}, '__input')
  121. if (nextinput > length(Inputs))
  122. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  123. end
  124. narglist{jj,2} = 'OK_in';
  125. nextinput = nextinput + 1;
  126. elseif strcmp(narglist{jj,2}, '__output')
  127. if (nextoutput > nargout)
  128. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  129. end
  130. if (isempty(arglist{ii,2}))
  131. narglist{jj,2} = 'OK_out';
  132. else
  133. narglist{jj,2} = arglist{ii,2};
  134. end
  135. nextoutput = nextoutput + 1;
  136. if (minval{jj} == 0)
  137. NumReqOutputs = NumReqOutputs - 1;
  138. end
  139. elseif isstr(arglist{ii,2})
  140. narglist{jj,2} = arglist{ii,2};
  141. else
  142. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  143. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  144. end
  145. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  146. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  147. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  148. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  149. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  150. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  151. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  152. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  153. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  154. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  155. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  156. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  157. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  158. end
  159. end
  160. end
  161. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  162. narglist{jj,2} = arglist{ii,2};
  163. end
  164. end
  165. end
  166. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  167. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  168. end
  169. end
  170. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  171. for jj=1:size(narglist,1)
  172. if strcmp(paramtype{jj}, 'Toggle')
  173. if (narglist{jj,2} ==0)
  174. narglist{jj,1} = '';
  175. end;
  176. narglist{jj,2} = '';
  177. end;
  178. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  179. narglist{jj,1} = '';
  180. narglist{jj,2} = '';
  181. end;
  182. if strcmp(narglist{jj,2}, '__input')
  183. if (minval{jj} == 0) % meaning this input is required
  184. if (nextinput > size(Inputs))
  185. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  186. else
  187. narglist{jj,2} = 'OK_in';
  188. nextinput = nextinput + 1;
  189. end
  190. else % this is an optional input
  191. if (nextinput <= length(Inputs))
  192. narglist{jj,2} = 'OK_in';
  193. nextinput = nextinput + 1;
  194. else
  195. narglist{jj,1} = '';
  196. narglist{jj,2} = '';
  197. end;
  198. end;
  199. else
  200. if strcmp(narglist{jj,2}, '__output')
  201. if (minval{jj} == 0) % this is a required output
  202. if (nextoutput > nargout & nargout > 1)
  203. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  204. else
  205. narglist{jj,2} = 'OK_out';
  206. nextoutput = nextoutput + 1;
  207. NumReqOutputs = NumReqOutputs-1;
  208. end
  209. else % this is an optional output
  210. if (nargout - nextoutput >= NumReqOutputs)
  211. narglist{jj,2} = 'OK_out';
  212. nextoutput = nextoutput + 1;
  213. else
  214. narglist{jj,1} = '';
  215. narglist{jj,2} = '';
  216. end;
  217. end
  218. end
  219. end
  220. end
  221. if nargout
  222. varargout = cell(1,nargout);
  223. else
  224. varargout = cell(0);
  225. end
  226. global KhorosRoot
  227. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  228. w=['"' KhorosRoot];
  229. else
  230. if ispc
  231. w='"C:\Program Files\dip\khorosBin\';
  232. else
  233. [s,w] = system('which cantata');
  234. w=['"' w(1:end-8)];
  235. end
  236. end
  237. callKhoros([w 'editimage" '],Inputs,narglist);