Skip to content
Snippets Groups Projects
Commit e4161e01 authored by Nicola Vigano's avatar Nicola Vigano
Browse files

gtCrop: added possibility to crop 2D images with 3D bboxes

parent 009e3147
No related branches found
No related tags found
No related merge requests found
......@@ -29,13 +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);
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), maxLims);
minLims = max(minLims, 1)
maxLims = min(size_img(1:2), maxLims)
img = img(minLims(2):maxLims(2), minLims(1):maxLims(1));
case 6
......@@ -45,7 +47,7 @@ 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, maxLims);
img = img(minLims(1):maxLims(1), minLims(2):maxLims(2), minLims(3):maxLims(3));
otherwise
......
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