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
cdd4eeac
Commit
cdd4eeac
authored
11 years ago
by
Laura Nervo
Browse files
Options
Downloads
Patches
Plain Diff
gtFindDirectBeamBB : using bbdir as variable, instead of bb not to get confused
Signed-off-by:
Laura Nervo
<
laura.nervo@esrf.fr
>
parent
33ac2499
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
1_preprocessing/gtFindDirectBeamBB.m
+35
-35
35 additions, 35 deletions
1_preprocessing/gtFindDirectBeamBB.m
with
35 additions
and
35 deletions
1_preprocessing/gtFindDirectBeamBB.m
+
35
−
35
View file @
cdd4eeac
function
bb
=
gtFindDirectBeamBB
(
acq
)
function
bb
dir
=
gtFindDirectBeamBB
(
acq
)
% GTFINDDIRECTBEAMBB Gives approximate bounding box of direct beam
% GTFINDDIRECTBEAMBB Gives approximate bounding box of direct beam
% bb = gtFindDirectBeamBB(acq)
% bb
dir
= gtFindDirectBeamBB(acq)
% ----------------------------
% ----------------------------
---
% INPUT:
% INPUT:
% acq = acquisition structure in parameters.mat
% acq = acquisition structure in parameters.mat
%
%
% OUTPUT:
% OUTPUT:
% bb
=
bounding box <double 1x4>
% bb
dir = direct beam
bounding box <double 1x4>
%
%
% Version 004 26/04/2012 by LNervo
% Version 004 26/04/2012 by LNervo
% Replace sprtinf by fullfile
% Replace sprtinf by fullfile
...
@@ -99,7 +99,7 @@ else % no images found!
...
@@ -99,7 +99,7 @@ else % no images found!
disp
(
'using a default guess'
);
disp
(
'using a default guess'
);
disp
(
'%%%%%%% missing images %%%%%%%%'
);
disp
(
'%%%%%%% missing images %%%%%%%%'
);
disp
(
' '
);
disp
(
' '
);
bb
=
[
512
512
1024
1024
];
bb
dir
=
[
512
512
1024
1024
];
return
return
end
end
...
@@ -116,36 +116,36 @@ marker = zeros(acq.ydet, acq.xdet);
...
@@ -116,36 +116,36 @@ marker = zeros(acq.ydet, acq.xdet);
marker
(
round
(
acq
.
ydet
/
2
),
round
(
acq
.
xdet
/
2
))
=
1
;
marker
(
round
(
acq
.
ydet
/
2
),
round
(
acq
.
xdet
/
2
))
=
1
;
cen
=
imreconstruct
(
marker
,
cen
);
cen
=
imreconstruct
(
marker
,
cen
);
tmp
=
regionprops
(
cen
,
'BoundingBox'
);
tmp
=
regionprops
(
cen
,
'BoundingBox'
);
bb
=
tmp
.
BoundingBox
;
bb
dir
=
tmp
.
BoundingBox
;
% Tighten bb until it's fully filled
% Tighten bb until it's fully filled
bb
=
[
ceil
(
bb
(
1
:
2
)),
bb
(
3
:
4
)
-
1
];
bb
dir
=
[
ceil
(
bb
dir
(
1
:
2
)),
bb
dir
(
3
:
4
)
-
1
];
goon
=
true
;
goon
=
true
;
while
goon
while
goon
cenbb
=
gtCrop
(
cen
,
bb
);
cenbb
=
gtCrop
(
cen
,
bb
dir
);
goon
=
false
;
goon
=
false
;
if
any
(
~
cenbb
(:,
1
))
% tighten bb on the left
if
any
(
~
cenbb
(:,
1
))
% tighten bb on the left
bb
(
1
)
=
bb
(
1
)
+
1
;
bb
dir
(
1
)
=
bb
dir
(
1
)
+
1
;
bb
(
3
)
=
bb
(
3
)
-
1
;
bb
dir
(
3
)
=
bb
dir
(
3
)
-
1
;
goon
=
true
;
goon
=
true
;
end
end
if
any
(
~
cenbb
(:,
end
))
% tighten bb on the right
if
any
(
~
cenbb
(:,
end
))
% tighten bb on the right
bb
(
3
)
=
bb
(
3
)
-
1
;
bb
dir
(
3
)
=
bb
dir
(
3
)
-
1
;
goon
=
true
;
goon
=
true
;
end
end
cenbb
=
gtCrop
(
cen
,
bb
);
cenbb
=
gtCrop
(
cen
,
bb
dir
);
if
any
(
~
cenbb
(
1
,
:))
% tighten bb at the top
if
any
(
~
cenbb
(
1
,
:))
% tighten bb at the top
bb
(
2
)
=
bb
(
2
)
+
1
;
bb
dir
(
2
)
=
bb
dir
(
2
)
+
1
;
bb
(
4
)
=
bb
(
4
)
-
1
;
bb
dir
(
4
)
=
bb
dir
(
4
)
-
1
;
goon
=
true
;
goon
=
true
;
end
end
if
any
(
~
cenbb
(
end
,
:))
% tighten bb at the bottom
if
any
(
~
cenbb
(
end
,
:))
% tighten bb at the bottom
bb
(
4
)
=
bb
(
4
)
-
1
;
bb
dir
(
4
)
=
bb
dir
(
4
)
-
1
;
goon
=
true
;
goon
=
true
;
end
end
end
end
...
@@ -155,54 +155,54 @@ goon = true;
...
@@ -155,54 +155,54 @@ goon = true;
while
goon
while
goon
goon
=
false
;
goon
=
false
;
tmpbb
=
bb
+
[
-
1
0
1
0
];
% loose bb on the left
tmpbb
=
bb
dir
+
[
-
1
0
1
0
];
% loose bb on the left
tmpim
=
gtCrop
(
cen
,
tmpbb
);
tmpim
=
gtCrop
(
cen
,
tmpbb
);
if
all
(
tmpim
(:))
if
all
(
tmpim
(:))
bb
=
tmpbb
;
bb
dir
=
tmpbb
;
goon
=
true
;
goon
=
true
;
end
end
tmpbb
=
bb
+
[
0
0
1
0
];
% loose bb on the right
tmpbb
=
bb
dir
+
[
0
0
1
0
];
% loose bb on the right
tmpim
=
gtCrop
(
cen
,
tmpbb
);
tmpim
=
gtCrop
(
cen
,
tmpbb
);
if
all
(
tmpim
(:))
if
all
(
tmpim
(:))
bb
=
tmpbb
;
bb
dir
=
tmpbb
;
goon
=
true
;
goon
=
true
;
end
end
tmpbb
=
bb
+
[
0
-
1
0
1
];
% loose bb at the top
tmpbb
=
bb
dir
+
[
0
-
1
0
1
];
% loose bb at the top
tmpim
=
gtCrop
(
cen
,
tmpbb
);
tmpim
=
gtCrop
(
cen
,
tmpbb
);
if
all
(
tmpim
(:))
if
all
(
tmpim
(:))
bb
=
tmpbb
;
bb
dir
=
tmpbb
;
goon
=
true
;
goon
=
true
;
end
end
tmpbb
=
bb
+
[
0
0
0
1
];
% loose bb at the bottom
tmpbb
=
bb
dir
+
[
0
0
0
1
];
% loose bb at the bottom
tmpim
=
gtCrop
(
cen
,
tmpbb
);
tmpim
=
gtCrop
(
cen
,
tmpbb
);
if
all
(
tmpim
(:))
if
all
(
tmpim
(:))
bb
=
tmpbb
;
bb
dir
=
tmpbb
;
goon
=
true
;
goon
=
true
;
end
end
end
end
% make sure the bbox width and height are even numbers (needed for correlation)
% make sure the bbox width and height are even numbers (needed for correlation)
bb
(
3
:
4
)
=
ceil
(
bb
(
3
:
4
)/
2
)
*
2
;
bb
dir
(
3
:
4
)
=
ceil
(
bb
dir
(
3
:
4
)/
2
)
*
2
;
% plot bbox found, its center-line and center-line of image
% plot bbox found, its center-line and center-line of image
bbcenter_abs
=
((
2
*
bb
(
1
))
+
bb
(
3
)
-
1
)/
2
;
bbcenter_abs
=
((
2
*
bb
dir
(
1
))
+
bb
dir
(
3
)
-
1
)/
2
;
hfig
=
figure
(
'name'
,
'Direct beam bounding box'
);
hfig
=
figure
(
'name'
,
'Direct beam bounding box'
);
iniZoomFactor
=
min
(
size
(
ref
)
.
/
bb
(
3
:
4
))
*
0.7
;
iniZoomFactor
=
min
(
size
(
ref
)
.
/
bb
dir
(
3
:
4
))
*
0.7
;
colormap
gray
;
colormap
gray
;
imagesc
(
ref
);
imagesc
(
ref
);
zoom
(
iniZoomFactor
);
zoom
(
iniZoomFactor
);
drawnow
;
drawnow
;
hold
on
;
hold
on
;
plot
([
bb
(
1
),
bb
(
1
)
+
bb
(
3
)
-
1
,
bb
(
1
)
+
bb
(
3
)
-
1
,
bb
(
1
),
bb
(
1
)],
[
bb
(
2
),
bb
(
2
),
bb
(
2
)
+
bb
(
4
)
-
1
,
bb
(
2
)
+
bb
(
4
)
-
1
,
bb
(
2
)],
'r-'
);
plot
([
bb
dir
(
1
),
bb
dir
(
1
)
+
bb
dir
(
3
)
-
1
,
bb
dir
(
1
)
+
bb
dir
(
3
)
-
1
,
bb
dir
(
1
),
bb
dir
(
1
)],
[
bb
dir
(
2
),
bb
dir
(
2
),
bb
dir
(
2
)
+
bb
dir
(
4
)
-
1
,
bb
dir
(
2
)
+
bb
dir
(
4
)
-
1
,
bb
dir
(
2
)],
'r-'
);
plot
([
acq
.
xdet
/
2
+
0.5
acq
.
xdet
/
2
+
0.5
],
[
1
acq
.
ydet
],
'b-.'
);
% centre of the ccd
plot
([
acq
.
xdet
/
2
+
0.5
acq
.
xdet
/
2
+
0.5
],
[
1
acq
.
ydet
],
'b-.'
);
% centre of the ccd
plot
([
bbcenter_abs
bbcenter_abs
],
[
bb
(
2
)
bb
(
2
)
+
bb
(
4
)
-
1
],
'c-.'
);
% centre of the direct beam
plot
([
bbcenter_abs
bbcenter_abs
],
[
bb
dir
(
2
)
bb
dir
(
2
)
+
bb
dir
(
4
)
-
1
],
'c-.'
);
% centre of the direct beam
% interactive check
% interactive check
questionMsg
=
'Are you satisfied with this bounding box for the direct beam? [y/n]'
;
questionMsg
=
'Are you satisfied with this bounding box for the direct beam? [y/n]'
;
...
@@ -211,21 +211,21 @@ while (strcmpi(inputwdefault(questionMsg, 'n'), 'n'))
...
@@ -211,21 +211,21 @@ while (strcmpi(inputwdefault(questionMsg, 'n'), 'n'))
disp
(
'-> please click top-left and bottom-right corners'
);
disp
(
'-> please click top-left and bottom-right corners'
);
figure
(
hfig
),
clf
,
imagesc
(
ref
),
zoom
(
iniZoomFactor
),
drawnow
,
hold
on
;
figure
(
hfig
),
clf
,
imagesc
(
ref
),
zoom
(
iniZoomFactor
),
drawnow
,
hold
on
;
bb
=
ginput
(
2
);
bb
dir
=
ginput
(
2
);
bb
=
round
([
bb
(
1
,
1
)
bb
(
1
,
2
)
bb
(
2
,
1
)
-
bb
(
1
,
1
)
+
1
bb
(
2
,
2
)
-
bb
(
1
,
2
)
+
1
]);
bb
dir
=
round
([
bb
dir
(
1
,
1
)
bb
dir
(
1
,
2
)
bb
dir
(
2
,
1
)
-
bb
dir
(
1
,
1
)
+
1
bb
dir
(
2
,
2
)
-
bb
dir
(
1
,
2
)
+
1
]);
% Make sure the bbox width and height are even numbers (needed for correlation)
% Make sure the bbox width and height are even numbers (needed for correlation)
bb
(
3
:
4
)
=
ceil
(
bb
(
3
:
4
)/
2
)
*
2
;
bb
dir
(
3
:
4
)
=
ceil
(
bb
dir
(
3
:
4
)/
2
)
*
2
;
% Reset figure
% Reset figure
zoomFactor
=
min
(
size
(
ref
)
.
/
bb
(
3
:
4
))
*
0.95
;
zoomFactor
=
min
(
size
(
ref
)
.
/
bb
dir
(
3
:
4
))
*
0.95
;
figure
(
hfig
),
clf
,
imagesc
(
ref
),
zoom
(
zoomFactor
),
drawnow
,
hold
on
;
figure
(
hfig
),
clf
,
imagesc
(
ref
),
zoom
(
zoomFactor
),
drawnow
,
hold
on
;
% Plot the new bounding box
% Plot the new bounding box
plot
([
bb
(
1
),
bb
(
1
)
+
bb
(
3
)
-
1
,
bb
(
1
)
+
bb
(
3
)
-
1
,
bb
(
1
),
bb
(
1
)],
[
bb
(
2
),
bb
(
2
),
bb
(
2
)
+
bb
(
4
)
-
1
,
bb
(
2
)
+
bb
(
4
)
-
1
,
bb
(
2
)],
'r-'
);
plot
([
bb
dir
(
1
),
bb
dir
(
1
)
+
bb
dir
(
3
)
-
1
,
bb
dir
(
1
)
+
bb
dir
(
3
)
-
1
,
bb
dir
(
1
),
bb
dir
(
1
)],
[
bb
dir
(
2
),
bb
dir
(
2
),
bb
dir
(
2
)
+
bb
dir
(
4
)
-
1
,
bb
dir
(
2
)
+
bb
dir
(
4
)
-
1
,
bb
dir
(
2
)],
'r-'
);
bbcenter_abs
=
((
2
*
bb
(
1
))
+
bb
(
3
)
-
1
)/
2
;
bbcenter_abs
=
((
2
*
bb
dir
(
1
))
+
bb
dir
(
3
)
-
1
)/
2
;
plot
([
acq
.
xdet
/
2
+
0.5
acq
.
xdet
/
2
+
0.5
],
[
1
acq
.
ydet
],
'b-.'
);
plot
([
acq
.
xdet
/
2
+
0.5
acq
.
xdet
/
2
+
0.5
],
[
1
acq
.
ydet
],
'b-.'
);
plot
([
bbcenter_abs
bbcenter_abs
],
[
bb
(
2
)
bb
(
2
)
+
bb
(
4
)
-
1
],
'c-.'
);
% centre of the direct beam
plot
([
bbcenter_abs
bbcenter_abs
],
[
bb
dir
(
2
)
bb
dir
(
2
)
+
bb
dir
(
4
)
-
1
],
'c-.'
);
% centre of the direct beam
end
end
close
(
hfig
);
close
(
hfig
);
...
...
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