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
923b404f
Commit
923b404f
authored
9 years ago
by
Nicola Vigano
Browse files
Options
Downloads
Patches
Plain Diff
gtCrop: added 4D cropping
Signed-off-by:
Nicola Vigano
<
nicola.vigano@esrf.fr
>
parent
7e2a3863
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
zUtil_Imaging/gtCrop.m
+16
-6
16 additions, 6 deletions
zUtil_Imaging/gtCrop.m
with
16 additions
and
6 deletions
zUtil_Imaging/gtCrop.m
+
16
−
6
View file @
923b404f
...
...
@@ -29,15 +29,15 @@ function img = gtCrop(img, gtbbox)
% Greg Johnson, September 2006
% Modified to work also with 3D volumes W. Ludwig, March 2012
[
size_img
(
1
),
size_img
(
2
),
size_img
(
3
)]
=
size
(
img
);
[
size_img
(
1
),
size_img
(
2
),
size_img
(
3
)
,
size_img
(
4
)
]
=
size
(
img
);
switch
(
length
(
gtbbox
))
case
4
% 2D case
minLims
=
gtbbox
(
1
:
2
)
maxLims
=
minLims
+
gtbbox
(
3
:
4
)
-
1
minLims
=
gtbbox
(
1
:
2
)
;
maxLims
=
minLims
+
gtbbox
(
3
:
4
)
-
1
;
% if bbox is too large, crop to image extent
minLims
=
max
(
minLims
,
1
)
maxLims
=
min
(
size_img
(
1
:
2
),
maxLims
)
minLims
=
max
(
minLims
,
1
)
;
maxLims
=
min
(
size_img
(
1
:
2
),
maxLims
)
;
img
=
img
(
minLims
(
2
):
maxLims
(
2
),
minLims
(
1
):
maxLims
(
1
));
case
6
...
...
@@ -47,9 +47,19 @@ function img = gtCrop(img, gtbbox)
maxLims
=
minLims
+
gtbbox
(
4
:
6
)
-
1
;
% if bbox is too large, crop to image extent
minLims
=
max
(
minLims
,
1
);
maxLims
=
min
(
size_img
,
maxLims
);
maxLims
=
min
(
size_img
(
1
:
3
)
,
maxLims
);
img
=
img
(
minLims
(
1
):
maxLims
(
1
),
minLims
(
2
):
maxLims
(
2
),
minLims
(
3
):
maxLims
(
3
));
case
8
% 4D case, uses different conventions from 2D case: x and y are not
% inverted
minLims
=
gtbbox
(
1
:
4
);
maxLims
=
minLims
+
gtbbox
(
5
:
8
)
-
1
;
% if bbox is too large, crop to image extent
minLims
=
max
(
minLims
,
1
);
maxLims
=
min
(
size_img
(
1
:
4
),
maxLims
);
img
=
img
(
minLims
(
1
):
maxLims
(
1
),
minLims
(
2
):
maxLims
(
2
),
minLims
(
3
):
maxLims
(
3
),
minLims
(
4
):
maxLims
(
4
));
otherwise
error
(
'gtCrop:wrongInput'
,
...
'Argument bbox needs either to be a 4 (2D) or 6 (3D) element vector'
);
...
...
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