|
1 | 1 | function varargout = show(obj, varargin) |
2 | | -% Shows image on current axis |
| 2 | +% Shows image on current axis. |
3 | 3 | % |
4 | | -% Image is displayed in its physical extent, based on image origin and |
5 | | -% spacing. |
| 4 | +% Image is displayed in its physical extent, based on image Origin and |
| 5 | +% Spacing properties. |
6 | 6 | % |
7 | 7 |
|
| 8 | +%% parse input arguments |
| 9 | + |
| 10 | +% default values |
| 11 | +showTitle = true; |
| 12 | +showAxisNames = true; |
| 13 | + |
| 14 | +% parse options |
| 15 | +options = {}; |
| 16 | +while length(varargin) > 1 |
| 17 | + if strcmp(varargin{1}, 'showAxisNames') |
| 18 | + else |
| 19 | + options = [options, varargin(1:2)]; %#ok<AGROW> |
| 20 | + end |
| 21 | + varargin(1:2) = []; |
| 22 | +end |
| 23 | +% options = varargin; |
| 24 | + |
| 25 | + |
8 | 26 | % Check image dimension: should be 2, or can be squeezed to 2. |
9 | 27 | if obj.Dimension ~= 2 |
10 | 28 | % compute number of image dimension |
|
19 | 37 | end |
20 | 38 | end |
21 | 39 |
|
22 | | -options = varargin; |
23 | | - |
| 40 | +%% Prepare data |
24 | 41 | data = getDisplayData(obj); |
25 | 42 |
|
26 | 43 | % if double, adjust grayscale extent |
|
32 | 49 | xdata = xData(obj); |
33 | 50 | ydata = yData(obj); |
34 | 51 |
|
| 52 | + |
| 53 | +%% Display data |
| 54 | + |
35 | 55 | % display image with approriate spatial reference |
36 | 56 | h = imshow(data, 'XData', xdata, 'YData', ydata, options{:}); |
37 | 57 |
|
|
44 | 64 | xlim(xl); ylim(yl); |
45 | 65 |
|
46 | 66 |
|
| 67 | +%% Annotate |
| 68 | + |
| 69 | +% show title |
| 70 | +if ~isempty(obj.Name) && showTitle |
| 71 | + title(obj.Name); |
| 72 | +end |
| 73 | + |
| 74 | +% show axis names |
| 75 | +if ~isempty(obj.AxisNames) && length(obj.AxisNames) >= 2 && showAxisNames |
| 76 | + xlabel(obj.AxisNames{1}) |
| 77 | + ylabel(obj.AxisNames{2}) |
| 78 | +end |
| 79 | + |
| 80 | + |
| 81 | +%% post-processing |
| 82 | + |
47 | 83 | % eventually returns handle to image object |
48 | 84 | if nargout > 0 |
49 | 85 | varargout = {h}; |
50 | 86 | end |
51 | 87 |
|
| 88 | + |
| 89 | +%% Inner functions |
52 | 90 | function options = updateDisplayRangeOptions(data, options) |
53 | 91 |
|
54 | 92 | % compute grayscale extent within image |
|
0 commit comments