Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
Main Repositories
otb
Commits
364674a4
Commit
364674a4
authored
10 years ago
by
Guillaume Pasero
Browse files
Options
Downloads
Patches
Plain Diff
BUG: Mantis-942 : fix output physical space
parent
2447cb76
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Applications/Projections/otbRigidTransformResample.cxx
+48
-37
48 additions, 37 deletions
Applications/Projections/otbRigidTransformResample.cxx
with
48 additions
and
37 deletions
Applications/Projections/otbRigidTransformResample.cxx
+
48
−
37
View file @
364674a4
...
...
@@ -230,12 +230,18 @@ private:
// Evaluate spacing
FloatVectorImageType
::
SpacingType
spacing
=
inputImage
->
GetSpacing
();
FloatVectorImageType
::
SpacingType
OutputSpacing
;
OutputSpacing
=
spacing
;
OutputSpacing
[
0
]
=
spacing
[
0
]
*
scale
[
0
];
OutputSpacing
[
1
]
=
spacing
[
1
]
*
scale
[
1
];
m_Resampler
->
SetOutputSpacing
(
OutputSpacing
);
FloatVectorImageType
::
PointType
origin
=
inputImage
->
GetOrigin
();
FloatVectorImageType
::
PointType
outputOrigin
;
outputOrigin
[
0
]
=
origin
[
0
]
+
0.5
*
spacing
[
0
]
*
(
scale
[
0
]
-
1.0
);
outputOrigin
[
1
]
=
origin
[
1
]
+
0.5
*
spacing
[
1
]
*
(
scale
[
1
]
-
1.0
);
m_Resampler
->
SetOutputOrigin
(
outputOrigin
);
m_Resampler
->
SetTransform
(
transform
);
// Evaluate size
...
...
@@ -267,13 +273,18 @@ private:
// Evaluate spacing
FloatVectorImageType
::
SpacingType
spacing
=
inputImage
->
GetSpacing
();
FloatVectorImageType
::
SpacingType
OutputSpacing
;
OutputSpacing
=
spacing
;
OutputSpacing
[
0
]
=
spacing
[
0
]
*
scale
[
0
];
OutputSpacing
[
1
]
=
spacing
[
1
]
*
scale
[
1
];
m_Resampler
->
SetOutputSpacing
(
OutputSpacing
);
FloatVectorImageType
::
PointType
origin
=
inputImage
->
GetOrigin
();
FloatVectorImageType
::
PointType
outputOrigin
;
outputOrigin
[
0
]
=
origin
[
0
]
+
0.5
*
spacing
[
0
]
*
(
scale
[
0
]
-
1.0
);
outputOrigin
[
1
]
=
origin
[
1
]
+
0.5
*
spacing
[
1
]
*
(
scale
[
1
]
-
1.0
);
m_Resampler
->
SetOutputOrigin
(
outputOrigin
);
ResampleFilterType
::
SizeType
recomputedSize
;
recomputedSize
[
0
]
=
inputImage
->
GetLargestPossibleRegion
().
GetSize
()[
0
]
/
scale
[
0
];
recomputedSize
[
1
]
=
inputImage
->
GetLargestPossibleRegion
().
GetSize
()[
1
]
/
scale
[
1
];
...
...
@@ -290,34 +301,33 @@ private:
{
ScalableTransformType
::
Pointer
transform
=
ScalableTransformType
::
New
();
FloatVectorImageType
::
IndexType
origin
=
inputImage
->
GetLargestPossibleRegion
().
Get
Index
();
FloatVectorImageType
::
SizeType
inSize
=
inputImage
->
GetLargestPossibleRegion
().
Get
Size
();
FloatVectorImageType
::
SpacingType
spacing
=
inputImage
->
GetSpacing
();
FloatVectorImageType
::
IndexType
center
;
center
[
0
]
=
origin
[
0
]
+
inputImage
->
GetLargestPossibleRegion
().
GetSize
()[
0
]
/
2.0
;
center
[
1
]
=
origin
[
1
]
+
inputImage
->
GetLargestPossibleRegion
().
GetSize
()[
1
]
/
2.0
;
itk
::
ContinuousIndex
<
double
,
2
>
ULindex
(
inputImage
->
GetLargestPossibleRegion
().
GetIndex
());
ULindex
[
0
]
+=
-
0.5
;
ULindex
[
1
]
+=
-
0.5
;
itk
::
ContinuousIndex
<
double
,
2
>
center
,
URindex
,
LRindex
,
LLindex
;
center
[
0
]
=
ULindex
[
0
]
+
static_cast
<
double
>
(
inSize
[
0
])
/
2.0
;
center
[
1
]
=
ULindex
[
1
]
+
static_cast
<
double
>
(
inSize
[
1
])
/
2.0
;
URindex
=
ULindex
;
LRindex
=
ULindex
;
LLindex
=
ULindex
;
URindex
[
0
]
+=
inSize
[
0
];
LRindex
[
0
]
+=
inSize
[
0
];
LRindex
[
1
]
+=
inSize
[
1
];
LLindex
[
1
]
+=
inSize
[
1
];
FloatVectorImageType
::
PointType
centerPoint
;
inputImage
->
TransformIndexToPhysicalPoint
(
center
,
centerPoint
);
inputImage
->
Transform
Continuous
IndexToPhysicalPoint
(
center
,
centerPoint
);
//image boundary
FloatVectorImageType
::
IndexType
ULindex
,
URindex
,
LRindex
,
LLindex
;
ULindex
[
0
]
=
origin
[
0
];
ULindex
[
1
]
=
origin
[
1
];
URindex
[
0
]
=
origin
[
0
]
+
inputImage
->
GetLargestPossibleRegion
().
GetSize
()[
0
];
URindex
[
1
]
=
origin
[
1
];
LRindex
[
0
]
=
origin
[
0
]
+
inputImage
->
GetLargestPossibleRegion
().
GetSize
()[
0
];
LRindex
[
1
]
=
origin
[
1
]
+
inputImage
->
GetLargestPossibleRegion
().
GetSize
()[
1
];
LLindex
[
0
]
=
origin
[
0
];
LLindex
[
1
]
=
origin
[
1
]
+
inputImage
->
GetLargestPossibleRegion
().
GetSize
()[
1
];
FloatVectorImageType
::
PointType
orig
,
ULpoint
,
URpoint
,
LRpoint
,
LLpoint
;
inputImage
->
TransformIndexToPhysicalPoint
(
ULindex
,
ULpoint
);
inputImage
->
TransformIndexToPhysicalPoint
(
URindex
,
URpoint
);
inputImage
->
TransformIndexToPhysicalPoint
(
LRindex
,
LRpoint
);
inputImage
->
TransformIndexToPhysicalPoint
(
LLindex
,
LLpoint
);
FloatVectorImageType
::
PointType
ULpoint
,
URpoint
,
LRpoint
,
LLpoint
;
inputImage
->
TransformContinuousIndexToPhysicalPoint
(
ULindex
,
ULpoint
);
inputImage
->
TransformContinuousIndexToPhysicalPoint
(
URindex
,
URpoint
);
inputImage
->
TransformContinuousIndexToPhysicalPoint
(
LRindex
,
LRpoint
);
inputImage
->
TransformContinuousIndexToPhysicalPoint
(
LLindex
,
LLpoint
);
// Scale Transform
OutputVectorType
scale
;
...
...
@@ -344,13 +354,11 @@ private:
m_Resampler
->
SetTransform
(
transform
);
FloatVectorImageType
::
PointType
ULpointTrans
,
URpointTrans
,
LRpointTrans
,
LLpointTrans
,
CenterPointTrans
;
FloatVectorImageType
::
PointType
ULpointTrans
,
URpointTrans
,
LRpointTrans
,
LLpointTrans
;
ULpointTrans
=
inverseTransform
->
TransformPoint
(
ULpoint
);
URpointTrans
=
inverseTransform
->
TransformPoint
(
URpoint
);
LRpointTrans
=
inverseTransform
->
TransformPoint
(
LRpoint
);
LLpointTrans
=
inverseTransform
->
TransformPoint
(
LLpoint
);
CenterPointTrans
=
inverseTransform
->
TransformPoint
(
centerPoint
);
//compute min and max
std
::
vector
<
FloatVectorImageType
::
PointType
>
voutput
;
...
...
@@ -364,7 +372,7 @@ private:
double
minY
=
voutput
[
0
][
1
];
double
maxY
=
voutput
[
0
][
1
];
for
(
unsigned
int
i
=
0
;
i
<
voutput
.
size
();
i
++
)
for
(
unsigned
int
i
=
1
;
i
<
voutput
.
size
();
i
++
)
{
// Origins
if
(
minX
>
voutput
[
i
][
0
]
)
...
...
@@ -387,16 +395,15 @@ private:
}
}
if
(
spacing
[
0
]
>
0
)
orig
[
0
]
=
minX
;
else
orig
[
0
]
=
maxX
;
FloatVectorImageType
::
PointType
outputOrig
;
if
(
spacing
[
0
]
>
0
)
outputOrig
[
0
]
=
minX
;
else
outputOrig
[
0
]
=
maxX
;
if
(
spacing
[
1
]
>
0
)
orig
[
1
]
=
minY
;
else
orig
[
1
]
=
maxY
;
m_Resampler
->
SetOutputOrigin
(
orig
);
if
(
spacing
[
1
]
>
0
)
outputOrig
[
1
]
=
minY
;
else
outputOrig
[
1
]
=
maxY
;
//size of output image
ResampleFilter
Type
::
Size
Type
size
;
FloatVectorImage
Type
::
Point
Type
size
;
size
[
0
]
=
vcl_abs
(
maxX
-
minX
);
size
[
1
]
=
vcl_abs
(
maxY
-
minY
);
...
...
@@ -407,6 +414,10 @@ private:
m_Resampler
->
SetOutputSpacing
(
OutputSpacing
);
outputOrig
[
0
]
+=
0.5
*
OutputSpacing
[
0
];
outputOrig
[
1
]
+=
0.5
*
OutputSpacing
[
1
];
m_Resampler
->
SetOutputOrigin
(
outputOrig
);
// Evaluate size
ResampleFilterType
::
SizeType
recomputedSize
;
recomputedSize
[
0
]
=
static_cast
<
unsigned
int
>
(
vcl_floor
(
vcl_abs
(
size
[
0
]
/
OutputSpacing
[
0
])));
...
...
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