Skip to content
Snippets Groups Projects
Commit dc5d9e33 authored by Nicola VIGANO's avatar Nicola VIGANO
Browse files

gtFigure: added point plotting, and fixed small bug with multiple insets


Signed-off-by: default avatarNicola VIGANO <N.R.Vigano@cwi.nl>
parent 40667033
No related branches found
No related tags found
No related merge requests found
......@@ -2,19 +2,20 @@ function gtFigureAddExtras(ax, im_props, extras)
% function gtFigureAddExtras(ax, im_props, extras)
num_extras = numel(extras);
original_image = permute(getimage(ax), [2 1 3]);
if (iscell(extras))
for ii_ex = 1:num_extras
apply_extras(ax, im_props, extras{ii_ex})
apply_extras(ax, im_props, extras{ii_ex}, original_image)
end
else
for ii_ex = 1:num_extras
apply_extras(ax, im_props, extras(ii_ex))
apply_extras(ax, im_props, extras(ii_ex), original_image)
end
end
end
function apply_extras(ax, im_props, extras)
function apply_extras(ax, im_props, extras, original_image)
switch (extras.type)
case 'unit_bar'
add_unit_bar(ax, im_props, extras);
......@@ -22,6 +23,8 @@ function apply_extras(ax, im_props, extras)
add_line(ax, im_props, extras)
case 'box'
add_box(ax, extras)
case 'point'
add_point(ax, extras)
case 'text'
add_text(ax, extras)
case 'arrow'
......@@ -29,7 +32,7 @@ function apply_extras(ax, im_props, extras)
case 'segment'
add_segment(ax, extras)
case 'inset_zoom'
add_inset(ax, extras, 'zoom')
add_inset(ax, extras, 'zoom', original_image)
case 'inset_image'
add_inset(ax, extras, 'image')
end
......@@ -118,6 +121,15 @@ function add_box(ax, ex_props)
'LineWidth', ex_props.line_width, 'LineStyle', ex_props.line_style)
end
function add_point(ax, ex_props)
x = ex_props.position(1);
y = ex_props.position(2);
hold(ax, 'on')
scatter(x, y, ex_props.size, ex_props.color, ex_props.style, 'filled', 'parent', ax);
hold(ax, 'off')
end
function add_text(ax, ex_props)
text(ex_props.position(1), ex_props.position(2), ex_props.string, ...
'parent', ax, 'Color', ex_props.color, ...
......@@ -149,11 +161,11 @@ function add_segment(ax, ex_props)
'LineWidth', ex_props.line_width, 'LineStyle', ex_props.line_style)
end
function add_inset(ax, ex_props, type)
function add_inset(ax, ex_props, type, original_image)
switch (lower(type))
case 'zoom'
cdata = permute(getimage(ax), [2 1 3]);
cdata = original_image;
method_type = 'nearest';
oversampling = [1, 1];
......@@ -177,6 +189,7 @@ function add_inset(ax, ex_props, type)
end
yy = linspace(region_start(1), region_end(1), ex_props.position(3) * oversampling(1));
xx = linspace(region_start(2), region_end(2), ex_props.position(4) * oversampling(2));
if (numel(size(cdata)) == 3)
zz = [1 2 3];
[xx, yy, zz] = ndgrid(xx, yy, zz);
......
......@@ -6,6 +6,8 @@ function extras = gtFigureCreateExtras(type, varargin)
extras = create_line(varargin{:});
case 'box'
extras = create_box(varargin{:});
case 'point'
extras = create_point(varargin{:});
case 'text'
extras = create_text(varargin{:});
case 'arrow'
......@@ -52,6 +54,15 @@ function extras = create_box(varargin)
extras = parse_pv_pairs(extras, varargin);
end
function extras = create_point(varargin)
extras = struct( ...
'size', 20, ...
'style', 'o', ...
'position', [1 1], ...
'color', [1 1 1] );
extras = parse_pv_pairs(extras, varargin);
end
function extras = create_text(varargin)
extras = struct( ...
'string', '', ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment