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

gtGetRawRoi: fixed loading spots close to image border

parent d8f688a0
No related branches found
No related tags found
No related merge requests found
......@@ -8,11 +8,17 @@ function [spot, m] = gtGetRawRoi(start_image, end_image, acq, bb)
nimages = end_image - start_image + 1;
spot = zeros(bb(4), bb(3), nimages);
m = zeros(nimages, 1);
centerx = round((bb(3)/2 -5) : (bb(3)/2 +5));
centery = round((bb(4)/2 -5) : (bb(4)/2 +5));
centeru = round((bb(3)/2 -5) : (bb(3)/2 +5));
centerv = round((bb(4)/2 -5) : (bb(4)/2 +5));
% Let's restrict the loading to "with-in" the limits
if all([bb(1)+bb(3) >= 1, bb(1) <= acq.xdet, bb(2)+bb(4) >= 1, bb(2) <= acq.ydet])
spot_range_u = (max(bb(1), 1) - bb(1) + 1):(min(bb(1)+bb(3)-1, acq.xdet) - bb(1) + 1);
spot_range_v = (max(bb(2), 1) - bb(2) + 1):(min(bb(2)+bb(4)-1, acq.ydet) - bb(2) + 1);
real_bb = [max(bb(1:2), 1), ...
(min(bb(1:2) + bb(3:4) - 1, [acq.xdet, acq.ydet]) - max(bb(1:2), 1) + 1)];
% was < acq.xdet and < acq.ydet
if all([bb(1) > 0, bb(2) > 0, bb(1)+bb(3) <= acq.xdet, bb(2)+bb(4) <= acq.ydet])
fullImgsDir = fullfile(acq.dir, '1_preprocessing', 'full');
indexes = mod(start_image : end_image, tot_images);
filename = fullfile(fullImgsDir, sprintf('full%04d.edf', indexes(1)));
......@@ -20,8 +26,8 @@ function [spot, m] = gtGetRawRoi(start_image, end_image, acq, bb)
for img_n = 1:nimages
fullImgName = fullfile(fullImgsDir, sprintf('full%04d.edf', indexes(img_n)));
spot(:, :, img_n) = edf_read(fullImgName, bb, [], info);
m(img_n) = gtImgMeanValue(spot(centery, centerx, img_n));
spot(spot_range_v, spot_range_u, img_n) = edf_read(fullImgName, real_bb, [], info);
m(img_n) = gtImgMeanValue(spot(centerv, centeru, img_n));
end
end
end
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