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
3a4f9945
Commit
3a4f9945
authored
8 years ago
by
Nicola Vigano
Browse files
Options
Downloads
Patches
Plain Diff
gtMathsGetInterpolationIndices: extended to 1D and 2D and simplified
Signed-off-by:
Nicola Vigano
<
nicola.vigano@esrf.fr
>
parent
0b10c073
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_Maths/gtMathsGetInterpolationIndices.m
+52
-60
52 additions, 60 deletions
zUtil_Maths/gtMathsGetInterpolationIndices.m
with
52 additions
and
60 deletions
zUtil_Maths/gtMathsGetInterpolationIndices.m
+
52
−
60
View file @
3a4f9945
function
[
inds8
,
ints8
]
=
gtMathsGetInterpolationIndices
(
pos
,
ints
,
data_type
,
mode
)
function
[
inds
,
ints
]
=
gtMathsGetInterpolationIndices
(
pos
,
pows
,
data_type
)
% FUNCTION [inds, ints] = gtMathsGetInterpolationIndices(pos, pows, data_type)
%
if
(
~
exist
(
'data_type'
,
'var'
)
||
isempty
(
data_type
))
if
(
~
exist
(
'data_type'
,
'var'
)
||
isempty
(
data_type
))
data_type
=
'single'
;
data_type
=
'single'
;
end
end
if
(
~
exist
(
'mode'
,
'var'
)
||
isempty
(
mode
))
pos
=
cast
(
pos
,
data_type
);
mode
=
'Nicola'
;
pows
=
cast
(
pows
,
data_type
);
pos_l
=
floor
(
pos
);
% lower position indices
pos_h
=
pos_l
+
1
;
% higher position indices
mu_l
=
pos_h
-
pos
;
mu_h
=
1
-
mu_l
;
n_dims
=
size
(
pos
,
2
);
switch
(
n_dims
)
case
3
% uvw indices of 8 nearest neighbours ((nx8) x 3)
inds
=
[
pos_l
;
...
[
pos_l
(:,
[
1
,
2
]),
pos_h
(:,
3
)
];
...
[
pos_l
(:,
1
),
pos_h
(:,
2
),
pos_l
(:,
3
)
];
...
[
pos_l
(:,
1
),
pos_h
(:,
[
2
,
3
])
];
...
[
pos_h
(:,
1
),
pos_l
(:,
[
2
,
3
])
];
...
[
pos_h
(:,
1
),
pos_l
(:,
2
),
pos_h
(:,
3
)
];
...
[
pos_h
(:,
[
1
,
2
]),
pos_l
(:,
3
)
];
...
pos_h
];
ints
=
[
...
mu_l
(:,
1
)
.*
mu_l
(:,
2
)
.*
mu_l
(:,
3
)
.*
pows
;
mu_l
(:,
1
)
.*
mu_l
(:,
2
)
.*
mu_h
(:,
3
)
.*
pows
;
mu_l
(:,
1
)
.*
mu_h
(:,
2
)
.*
mu_l
(:,
3
)
.*
pows
;
mu_l
(:,
1
)
.*
mu_h
(:,
2
)
.*
mu_h
(:,
3
)
.*
pows
;
mu_h
(:,
1
)
.*
mu_l
(:,
2
)
.*
mu_l
(:,
3
)
.*
pows
;
mu_h
(:,
1
)
.*
mu_l
(:,
2
)
.*
mu_h
(:,
3
)
.*
pows
;
mu_h
(:,
1
)
.*
mu_h
(:,
2
)
.*
mu_l
(:,
3
)
.*
pows
;
mu_h
(:,
1
)
.*
mu_h
(:,
2
)
.*
mu_h
(:,
3
)
.*
pows
];
case
2
inds
=
[
pos_l
;
...
[
pos_l
(:,
1
),
pos_h
(:,
2
)
];
...
[
pos_h
(:,
1
),
pos_l
(:,
2
)
];
...
pos_h
];
ints
=
[
...
mu_l
(:,
1
)
.*
mu_l
(:,
2
)
.*
pows
;
mu_l
(:,
1
)
.*
mu_h
(:,
2
)
.*
pows
;
mu_h
(:,
1
)
.*
mu_l
(:,
2
)
.*
pows
;
mu_h
(:,
1
)
.*
mu_h
(:,
2
)
.*
pows
];
case
1
inds
=
[
pos_l
;
pos_h
];
ints
=
[
mu_l
.*
pows
;
mu_h
.*
pows
];
otherwise
error
(
'gtMathsGetInterpolationIndices:wrong_argument'
,
...
'Interpolation can only be done for 1D, 2D and 3D positions'
)
end
end
pos_l
=
floor
(
pos
);
% lower pixel indices
pos_h
=
pos_l
+
1
;
% higher pixel indices
% uvw indices of 8 nearest neighbours ((nx8) x 3)
inds8
=
[
pos_l
;
...
[
pos_l
(:,
[
1
,
2
]),
pos_h
(:,
3
)
];
...
[
pos_l
(:,
1
),
pos_h
(:,
2
),
pos_l
(:,
3
)
];
...
[
pos_l
(:,
1
),
pos_h
(:,
[
2
,
3
])
];
...
[
pos_h
(:,
1
),
pos_l
(:,
[
2
,
3
])
];
...
[
pos_h
(:,
1
),
pos_l
(:,
2
),
pos_h
(:,
3
)
];
...
[
pos_h
(:,
[
1
,
2
]),
pos_l
(:,
3
)
];
...
pos_h
];
ints8
=
zeros
(
numel
(
ints
),
8
,
data_type
);
% Output is identical, but Nicola and Peter like to do the same thing
% in a different way :)
switch
(
mode
)
case
'Peter'
% This way of rounding is correct also for round values when
% mu=mod... is used above:
% Modulus of uvw position
mu
=
mod
(
pos
,
1
);
mu1
=
mu
(:,
1
);
mu2
=
mu
(:,
2
);
mu3
=
mu
(:,
3
);
mu12
=
mu1
.*
mu2
;
mu13
=
mu1
.*
mu3
;
mu23
=
mu2
.*
mu3
;
mu123
=
mu12
.*
mu3
;
ints8
(:,
1
)
=
mu12
+
mu13
+
mu23
-
mu1
-
mu2
-
mu3
+
-
mu123
+
1
;
ints8
(:,
2
)
=
mu3
-
mu13
-
mu23
+
mu123
;
ints8
(:,
3
)
=
mu2
-
mu12
-
mu23
+
mu123
;
ints8
(:,
4
)
=
mu23
-
mu123
;
ints8
(:,
5
)
=
mu1
-
mu12
-
mu13
+
mu123
;
ints8
(:,
6
)
=
mu13
-
mu123
;
ints8
(:,
7
)
=
mu12
-
mu123
;
ints8
(:,
8
)
=
mu123
;
ints8
=
ints8
.*
ints
(:,
[
1
1
1
1
1
1
1
1
]);
case
'Nicola'
mu_l
=
pos_h
-
pos
;
mu_h
=
1
-
mu_l
;
ints8
(:,
1
)
=
mu_l
(:,
1
)
.*
mu_l
(:,
2
)
.*
mu_l
(:,
3
)
.*
ints
;
ints8
(:,
2
)
=
mu_l
(:,
1
)
.*
mu_l
(:,
2
)
.*
mu_h
(:,
3
)
.*
ints
;
ints8
(:,
3
)
=
mu_l
(:,
1
)
.*
mu_h
(:,
2
)
.*
mu_l
(:,
3
)
.*
ints
;
ints8
(:,
4
)
=
mu_l
(:,
1
)
.*
mu_h
(:,
2
)
.*
mu_h
(:,
3
)
.*
ints
;
ints8
(:,
5
)
=
mu_h
(:,
1
)
.*
mu_l
(:,
2
)
.*
mu_l
(:,
3
)
.*
ints
;
ints8
(:,
6
)
=
mu_h
(:,
1
)
.*
mu_l
(:,
2
)
.*
mu_h
(:,
3
)
.*
ints
;
ints8
(:,
7
)
=
mu_h
(:,
1
)
.*
mu_h
(:,
2
)
.*
mu_l
(:,
3
)
.*
ints
;
ints8
(:,
8
)
=
mu_h
(:,
1
)
.*
mu_h
(:,
2
)
.*
mu_h
(:,
3
)
.*
ints
;
end
ints8
=
reshape
(
ints8
,
[],
1
);
end
end
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