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
e1730b3e
Commit
e1730b3e
authored
8 years ago
by
Nicola Vigano
Browse files
Options
Downloads
Patches
Plain Diff
Gradient/divergence: Reduced their performance impact
Signed-off-by:
Nicola Vigano
<
nicola.vigano@esrf.fr
>
parent
1fbcb871
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
5_reconstruction/gtAstra3DTV.m
+6
-20
6 additions, 20 deletions
5_reconstruction/gtAstra3DTV.m
zUtil_Maths/gtMathsDivergence.m
+11
-13
11 additions, 13 deletions
zUtil_Maths/gtMathsDivergence.m
zUtil_Maths/gtMathsGradient.m
+10
-8
10 additions, 8 deletions
zUtil_Maths/gtMathsGradient.m
with
27 additions
and
41 deletions
5_reconstruction/gtAstra3DTV.m
+
6
−
20
View file @
e1730b3e
...
...
@@ -219,9 +219,9 @@ function output = projection(algo_id, output_id, input_id, input)
end
function
d
=
gradient
(
vol
)
dx
=
cat
(
1
,
vol
(
2
:
end
,
:,
:)
-
vol
(
1
:
end
-
1
,
:,
:),
-
vol
(
end
,
:
,
:)
);
dy
=
cat
(
2
,
vol
(:,
2
:
end
,
:)
-
vol
(:,
1
:
end
-
1
,
:),
-
vol
(:,
end
,
:)
);
dz
=
cat
(
3
,
vol
(:,
:,
2
:
end
)
-
vol
(:,
:,
1
:
end
-
1
),
-
vol
(:
,
:
,
end
)
);
dx
=
diff
(
padarray
(
vol
,
[
1
0
0
],
'post'
)
,
1
,
1
);
dy
=
diff
(
padarray
(
vol
,
[
0
1
0
],
'post'
),
1
,
2
);
dz
=
diff
(
padarray
(
vol
,
[
0
0
1
],
'post'
)
,
1
,
3
);
d
=
cat
(
4
,
dx
,
dy
,
dz
);
end
...
...
@@ -229,22 +229,8 @@ function vol = divergence(d)
dx
=
d
(:,
:,
:,
1
);
dy
=
d
(:,
:,
:,
2
);
dz
=
d
(:,
:,
:,
3
);
ddx
=
cat
(
1
,
dx
(
1
,
:,
:),
dx
(
2
:
end
,
:,
:)
-
dx
(
1
:
end
-
1
,
:
,
:)
);
ddy
=
cat
(
2
,
dy
(:,
1
,
:),
dy
(:,
2
:
end
,
:)
-
dy
(:,
1
:
end
-
1
,
:)
);
ddz
=
cat
(
3
,
dz
(:,
:,
1
),
dz
(:,
:,
2
:
end
)
-
dz
(:
,
:
,
1
:
end
-
1
)
);
ddx
=
diff
(
padarray
(
dx
,
[
1
0
0
],
'pre'
)
,
1
,
1
);
ddy
=
diff
(
padarray
(
dy
,
[
0
1
0
],
'pre'
),
1
,
2
);
ddz
=
diff
(
padarray
(
dz
,
[
0
0
1
],
'pre'
)
,
1
,
3
);
vol
=
ddx
+
ddy
+
ddz
;
end
% function d = gradient2D(vol)
% dx = cat(1, vol(1:end-1, :, :) - vol(2:end, :, :), vol(end, :, :));
% dy = cat(2, vol(:, 1:end-1, :) - vol(:, 2:end, :), vol(:, end, :));
% d = cat(4, dx, dy, dz);
% end
%
% function vol = divergence2D(d)
% dx = d(:, :, :, 1);
% dy = d(:, :, :, 2);
% ddx = cat(1, -dx(1, :, :), dx(1:end-1, :, :) - dx(2:end, :, :));
% ddy = cat(2, -dy(:, 1, :), dy(:, 1:end-1, :) - dy(:, 2:end, :));
% vol = ddx + ddy;
% end
This diff is collapsed.
Click to expand it.
zUtil_Maths/gtMathsDivergence.m
+
11
−
13
View file @
e1730b3e
function
d
d
=
gtMathsDivergence
(
d
)
% FUNCTION d = gtMathsDivergence(
d
)
% Computes the divergence of a
1D-2D-3D
object.
function
d
=
gtMathsDivergence
(
x
)
% FUNCTION d = gtMathsDivergence(
x
)
% Computes the divergence of a
n n-dimensional vector
object.
if
(
numel
(
d
)
>=
3
)
d
z
=
d
{
3
}
;
dd
{
3
}
=
cat
(
3
,
dz
(:,
:,
1
),
dz
(:,
:,
2
:
end
)
-
dz
(:,
:,
1
:
end
-
1
));
end
if
(
numel
(
d
)
>
=
2
)
dy
=
d
{
2
};
d
d
{
2
}
=
cat
(
2
,
dy
(:,
1
,
:),
dy
(:,
2
:
end
,
:)
-
dy
(:,
1
:
end
-
1
,
:)
);
num_dims
=
numel
(
x
);
d
=
cell
(
num_dims
,
1
)
;
for
ii_d
=
1
:
num_dims
padsize
=
zeros
(
1
,
num_dims
);
padsize
(
ii_
d
)
=
1
;
d
{
ii_d
}
=
diff
(
padarray
(
x
{
ii_d
},
padsize
,
'pre'
),
1
,
ii_d
);
end
dx
=
d
{
1
};
dd
{
1
}
=
cat
(
1
,
dx
(
1
,
:,
:),
dx
(
2
:
end
,
:,
:)
-
dx
(
1
:
end
-
1
,
:,
:));
d
d
=
gtMathsSumCellVolumes
(
d
d
);
d
=
gtMathsSumCellVolumes
(
d
);
end
\ No newline at end of file
This diff is collapsed.
Click to expand it.
zUtil_Maths/gtMathsGradient.m
+
10
−
8
View file @
e1730b3e
function
d
=
gtMathsGradient
(
x
)
% FUNCTION d = gtMathsGradient(
vol
)
% Computes the gradient of a
1D-2D-3D
object and outputs a cell
% FUNCTION d = gtMathsGradient(
x
)
% Computes the gradient of a
n n-dimensional
object and outputs a cell
% concatenation of the directional gradients.
if
(
size
(
x
,
3
)
>
1
)
d
{
3
}
=
cat
(
3
,
x
(:,
:,
2
:
end
)
-
x
(:,
:,
1
:
end
-
1
),
-
x
(:,
:,
end
));
end
if
(
size
(
x
,
2
)
>
1
)
d
{
2
}
=
cat
(
2
,
x
(:,
2
:
end
,
:)
-
x
(:,
1
:
end
-
1
,
:),
-
x
(:,
end
,
:));
dims
=
size
(
x
);
num_dims
=
numel
(
dims
);
d
=
cell
(
num_dims
,
1
);
for
ii_d
=
1
:
num_dims
padsize
=
zeros
(
1
,
num_dims
);
padsize
(
ii_d
)
=
1
;
d
{
ii_d
}
=
diff
(
padarray
(
x
,
padsize
,
'post'
),
1
,
ii_d
);
end
d
{
1
}
=
cat
(
1
,
x
(
2
:
end
,
:,
:)
-
x
(
1
:
end
-
1
,
:,
:),
-
x
(
end
,
:,
:));
end
\ No newline at end of file
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