comparison scripts/image/imshow.m @ 20336:eca5aa3225f4

imshow.m: Add support for 'parent' property (bug #45473). * imshow.m: Add cell variable prop_val_args{:} when calling image or imagesc. Populate prop_val_args with {"parent", hparent} when "parent" argument given to imshow. Remove code commented out in 2015/05/1 which has not caused any problems. Add warning that arguments "border" and "reduce" are not supported.
author Rik <rik@octave.org>
date Sun, 05 Jul 2015 13:55:56 -0700
parents aa36fb998a4d
children 928e2c6f888e
comparison
equal deleted inserted replaced
20335:9de6949ec15f 20336:eca5aa3225f4
75 75
76 display_range = NA; 76 display_range = NA;
77 truecolor = false; 77 truecolor = false;
78 indexed = false; 78 indexed = false;
79 xdata = ydata = []; 79 xdata = ydata = [];
80 prop_val_args = {};
80 81
81 ## Get the image. 82 ## Get the image.
82 if (ischar (im)) 83 if (ischar (im))
83 [im, map] = imread (im); 84 [im, map] = imread (im);
84 indexed = true; 85 indexed = true;
121 elseif (! isempty (arg)) 122 elseif (! isempty (arg))
122 error ("imshow: argument number %d is invalid", narg); 123 error ("imshow: argument number %d is invalid", narg);
123 endif 124 endif
124 elseif (ischar (arg)) 125 elseif (ischar (arg))
125 switch (tolower (arg)) 126 switch (tolower (arg))
127 case "border"
128 warning ("imshow: border argument is not implemented");
129 narg++;
126 case "colormap" 130 case "colormap"
127 map = varargin{narg++}; 131 map = varargin{narg++};
128 if (iscolormap (map)) 132 if (iscolormap (map))
129 colormap (map); 133 colormap (map);
130 else 134 else
131 error ("imshow: invalid colormap"); 135 error ("imshow: invalid colormap");
132 endif 136 endif
133 case "displayrange" 137 case "displayrange"
134 display_range = varargin{narg++}; 138 display_range = varargin{narg++};
139 case {"initialmagnification"}
140 warning ("image: zoom argument ignored -- use GUI features");
141 narg++;
135 case "parent" 142 case "parent"
136 warning ("imshow: parent argument is not implemented"); 143 prop_val_args(end+(1:2)) = {"parent", varargin{narg++}};
137 case {"truesize", "initialmagnification"} 144 case "reduce"
138 warning ("image: zoom argument ignored -- use GUI features"); 145 warning ("imshow: reduce argument is not implemented");
146 narg++;
139 case "xdata" 147 case "xdata"
140 xdata = varargin{narg++}; 148 xdata = varargin{narg++};
141 if (! isvector (xdata)) 149 if (! isvector (xdata))
142 error ("imshow: xdata must be a vector") 150 error ("imshow: xdata must be a vector")
143 endif 151 endif
185 "imshow: pixels with NaN or NA values are set to minimum pixel value"); 193 "imshow: pixels with NaN or NA values are set to minimum pixel value");
186 im(nans) = display_range(1); 194 im(nans) = display_range(1);
187 endif 195 endif
188 endif 196 endif
189 197
190 ## FIXME: Commented out 2014/05/01. imagesc and 'clim' will automatically
191 ## take care of displaying out-of-range data clamped to the limits.
192 ## Eventually, this can be deleted if no problems arise.
193 ## Clamp the image to the range boundaries
194 ##if (! (truecolor || indexed || islogical (im)))
195 ## low = display_range(1);
196 ## high = display_range(2);
197 ## im(im < low) = low;
198 ## im(im > high) = high;
199 ##endif
200
201 if (truecolor || indexed) 198 if (truecolor || indexed)
202 htmp = image (xdata, ydata, im); 199 htmp = image (xdata, ydata, im, prop_val_args{:});
203 else 200 else
204 htmp = imagesc (xdata, ydata, im, display_range); 201 htmp = imagesc (xdata, ydata, im, display_range, prop_val_args{:});
205 set (gca (), "clim", display_range); 202 set (gca (), "clim", display_range);
206 endif 203 endif
207 set (gca (), "visible", "off", "view", [0, 90], 204 set (gca (), "visible", "off", "view", [0, 90],
208 "ydir", "reverse", "layer", "top"); 205 "ydir", "reverse", "layer", "top");
209 axis ("image"); 206 axis ("image");