Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DCT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
graintracking
DCT
Commits
76788817
Commit
76788817
authored
7 years ago
by
Nicola Vigano
Browse files
Options
Downloads
Patches
Plain Diff
Figures-extras: added image inset generation
Signed-off-by:
Nicola Vigano
<
nicola.vigano@esrf.fr
>
parent
fa752294
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
zUtil_Drawing/gtFigureAddExtras.m
+34
-14
34 additions, 14 deletions
zUtil_Drawing/gtFigureAddExtras.m
zUtil_Drawing/gtFigureCreateExtras.m
+15
-3
15 additions, 3 deletions
zUtil_Drawing/gtFigureCreateExtras.m
with
49 additions
and
17 deletions
zUtil_Drawing/gtFigureAddExtras.m
+
34
−
14
View file @
76788817
...
...
@@ -28,8 +28,10 @@ function apply_extras(ax, im_props, extras)
add_arrow
(
ax
,
extras
)
case
'segment'
add_segment
(
ax
,
extras
)
case
'inset'
add_inset
(
ax
,
extras
)
case
'inset_zoom'
add_inset
(
ax
,
extras
,
'zoom'
)
case
'inset_image'
add_inset
(
ax
,
extras
,
'image'
)
end
end
...
...
@@ -147,25 +149,46 @@ function add_segment(ax, ex_props)
'LineWidth'
,
ex_props
.
line_width
,
'LineStyle'
,
ex_props
.
line_style
)
end
function
add_inset
(
ax
,
ex_props
)
function
add_inset
(
ax
,
ex_props
,
type
)
cdata
=
permute
(
getimage
(
ax
),
[
2
1
3
]);
switch
(
lower
(
type
))
case
'zoom'
cdata
=
permute
(
getimage
(
ax
),
[
2
1
3
]);
shifts
=
min
(
ex_props
.
region
(
3
:
4
)
.
/
ex_props
.
position
(
3
:
4
)
-
0.5
,
0
);
region_start
=
ex_props
.
region
(
1
:
2
)
+
shifts
;
region_end
=
ex_props
.
region
(
1
:
2
)
+
ex_props
.
region
(
3
:
4
)
-
1
-
shifts
;
yy
=
linspace
(
region_start
(
1
),
region_end
(
1
),
ex_props
.
position
(
3
));
xx
=
linspace
(
region_start
(
2
),
region_end
(
2
),
ex_props
.
position
(
4
));
method_type
=
'nearest'
;
oversampling
=
[
1
,
1
];
shifts
=
min
(
ex_props
.
region
(
3
:
4
)
.
/
ex_props
.
position
(
3
:
4
)
-
0.5
,
0
);
region_start
=
ex_props
.
region
(
1
:
2
)
+
shifts
;
region_end
=
ex_props
.
region
(
1
:
2
)
+
ex_props
.
region
(
3
:
4
)
-
1
-
shifts
;
case
'image'
cdata
=
im2double
(
permute
(
ex_props
.
image
,
[
2
1
3
]));
region
=
[
1
,
1
,
size
(
cdata
,
1
),
size
(
cdata
,
2
)];
method_type
=
'nearest'
;
oversampling
=
ceil
(
region
(
3
:
4
)
.
/
ex_props
.
position
(
3
:
4
));
shifts
=
min
(
region
(
3
:
4
)
.
/
(
ex_props
.
position
(
3
:
4
)
.*
oversampling
)
-
0.5
,
0
);
region_start
=
region
(
1
:
2
)
+
shifts
;
region_end
=
region
(
1
:
2
)
+
region
(
3
:
4
)
-
1
-
shifts
;
otherwise
error
(
'gtFigureAddExtras:wrong_argument'
,
...
'No known inset type: %s'
,
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
);
inset_data
=
interp3
(
cdata
,
xx
,
yy
,
zz
,
'nearest'
);
inset_data
=
interp3
(
cdata
,
xx
,
yy
,
zz
,
method_type
,
0
);
else
[
xx
,
yy
]
=
ndgrid
(
xx
,
yy
);
inset_data
=
interp2
(
cdata
,
xx
,
yy
,
'nearest'
);
inset_data
=
interp2
(
cdata
,
xx
,
yy
,
method_type
,
0
);
end
inset_data
=
reshape
(
inset_data
,
oversampling
(
2
),
ex_props
.
position
(
4
),
oversampling
(
1
),
ex_props
.
position
(
3
),
[]);
inset_data
=
squeeze
(
sum
(
sum
(
inset_data
,
1
),
3
))
/
prod
(
oversampling
);
hold
(
ax
,
'on'
)
% watch out for the inversion of coordinates xx and yy here
...
...
@@ -175,8 +198,5 @@ function add_inset(ax, ex_props)
hold
(
ax
,
'off'
)
add_box
(
ax
,
ex_props
);
ex_props_region
=
ex_props
;
ex_props_region
.
position
=
ex_props_region
.
region
;
add_box
(
ax
,
ex_props_region
);
end
This diff is collapsed.
Click to expand it.
zUtil_Drawing/gtFigureCreateExtras.m
+
15
−
3
View file @
76788817
...
...
@@ -12,8 +12,10 @@ function extras = gtFigureCreateExtras(type, varargin)
extras = create_arrow(varargin{:});
case 'segment'
extras = create_segment(varargin{:});
case 'inset'
extras = create_inset(varargin{:});
case 'inset_zoom'
extras = create_inset_zoom(varargin{:});
case 'inset_image'
extras = create_inset_image(varargin{:});
end
extras.type = type;
end
...
...
@@ -84,7 +86,7 @@ function extras = create_segment(varargin)
extras = parse_pv_pairs(extras, varargin);
end
function extras = create_inset(varargin)
function extras = create_inset
_zoom
(varargin)
extras = struct( ...
'line_width', 1, ...
'line_style', '-', ...
...
...
@@ -94,3 +96,13 @@ function extras = create_inset(varargin)
extras = parse_pv_pairs(extras, varargin);
end
function extras = create_inset_image(varargin)
extras = struct( ...
'line_width', 1, ...
'line_style', '-', ...
'image', [], ...
'position', [1 1 10 10], ...
'color', [1 1 1] );
extras = parse_pv_pairs(extras, varargin);
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment