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
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
David Youssefi
otb
Commits
ad9da8c5
Commit
ad9da8c5
authored
16 years ago
by
Julien Michel
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Missing GenerateInputRequestedRegion().
parent
24225ec8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/Common/otbBinaryFunctorNeighborhoodImageFilter.h
+17
-6
17 additions, 6 deletions
Code/Common/otbBinaryFunctorNeighborhoodImageFilter.h
Code/Common/otbBinaryFunctorNeighborhoodImageFilter.txx
+104
-2
104 additions, 2 deletions
Code/Common/otbBinaryFunctorNeighborhoodImageFilter.txx
with
121 additions
and
8 deletions
Code/Common/otbBinaryFunctorNeighborhoodImageFilter.h
+
17
−
6
View file @
ad9da8c5
...
...
@@ -55,13 +55,15 @@ public:
/** Some convenient typedefs. */
typedef
TFunction
FunctorType
;
typedef
TInputImage1
Input1ImageType
;
typedef
typename
Input1ImageType
::
ConstPointer
Input1ImagePointer
;
typedef
typename
Input1ImageType
::
RegionType
Input1ImageRegionType
;
typedef
typename
Input1ImageType
::
PixelType
Input1ImagePixelType
;
typedef
typename
Input1ImageType
::
ConstPointer
Input1ImageConstPointer
;
typedef
typename
Input1ImageType
::
Pointer
Input1ImagePointer
;
typedef
typename
Input1ImageType
::
RegionType
Input1ImageRegionType
;
typedef
typename
Input1ImageType
::
PixelType
Input1ImagePixelType
;
typedef
TInputImage2
Input2ImageType
;
typedef
typename
Input2ImageType
::
ConstPointer
Input2ImagePointer
;
typedef
typename
Input2ImageType
::
RegionType
Input2ImageRegionType
;
typedef
typename
Input2ImageType
::
PixelType
Input2ImagePixelType
;
typedef
typename
Input2ImageType
::
ConstPointer
Input2ImageConstPointer
;
typedef
typename
Input2ImageType
::
Pointer
Input2ImagePointer
;
typedef
typename
Input2ImageType
::
RegionType
Input2ImageRegionType
;
typedef
typename
Input2ImageType
::
PixelType
Input2ImagePixelType
;
typedef
TOutputImage
OutputImageType
;
typedef
typename
OutputImageType
::
Pointer
OutputImagePointer
;
typedef
typename
OutputImageType
::
RegionType
OutputImageRegionType
;
...
...
@@ -76,6 +78,10 @@ public:
/** Connect one of the operands for pixel-wise addition */
void
SetInput2
(
const
TInputImage2
*
image2
);
/** Get the inputs */
const
TInputImage1
*
GetInput1
();
const
TInputImage2
*
GetInput2
();
/** Get the functor object. The functor is returned by reference.
* (Functors do not have to derive from itk::LightObject, so they do
* not necessarily have a reference count. So we cannot return a
...
...
@@ -125,6 +131,11 @@ protected:
virtual
void
ThreadedGenerateData
(
const
OutputImageRegionType
&
outputRegionForThread
,
int
threadId
);
/**
* Pad the inputs requested regions by radius
*/
virtual
void
GenerateInputRequestedRegion
(
void
);
RadiusSizeType
m_Radius
;
private
:
...
...
This diff is collapsed.
Click to expand it.
Code/Common/otbBinaryFunctorNeighborhoodImageFilter.txx
+
104
−
2
View file @
ad9da8c5
...
...
@@ -67,7 +67,109 @@ BinaryFunctorNeighborhoodImageFilter<TInputImage1,TInputImage2,TOutputImage,TFun
SetNthInput(1, const_cast<TInputImage2 *>( image2 ));
}
template <class TInputImage1, class TInputImage2,
class TOutputImage, class TFunction >
const TInputImage1 *
BinaryFunctorNeighborhoodImageFilter<TInputImage1,TInputImage2,TOutputImage,TFunction>
::GetInput1()
{
if(this->GetNumberOfInputs()<1)
{
return 0;
}
return static_cast<const TInputImage1 *>(this->itk::ProcessObject::GetInput(0));
}
template <class TInputImage1, class TInputImage2,
class TOutputImage, class TFunction >
const TInputImage2 *
BinaryFunctorNeighborhoodImageFilter<TInputImage1,TInputImage2,TOutputImage,TFunction>
::GetInput2()
{
if(this->GetNumberOfInputs()<2)
{
return 0;
}
return static_cast<const TInputImage2 *>(this->itk::ProcessObject::GetInput(1));
}
template <class TInputImage1, class TInputImage2,
class TOutputImage, class TFunction >
void
BinaryFunctorNeighborhoodImageFilter<TInputImage1,TInputImage2,TOutputImage,TFunction>
::GenerateInputRequestedRegion()
{
// call the superclass' implementation of this method
Superclass::GenerateInputRequestedRegion();
// get pointers to the input and output
Input1ImagePointer inputPtr1 =
const_cast< TInputImage1 * >( this->GetInput1());
Input2ImagePointer inputPtr2 =
const_cast< TInputImage2 * >( this->GetInput2());
typename Superclass::OutputImagePointer outputPtr = this->GetOutput();
if ( !inputPtr1 || !inputPtr2 || !outputPtr )
{
return;
}
// get a copy of the input requested region (should equal the output
// requested region)
typename TInputImage1::RegionType inputRequestedRegion1, inputRequestedRegion2;
inputRequestedRegion1 = inputPtr1->GetRequestedRegion();
// pad the input requested region by the operator radius
inputRequestedRegion1.PadByRadius( m_Radius );
inputRequestedRegion2 = inputRequestedRegion1;
// crop the input requested region at the input's largest possible region
if ( inputRequestedRegion1.Crop(inputPtr1->GetLargestPossibleRegion()))
{
inputPtr1->SetRequestedRegion( inputRequestedRegion1 );
}
else
{
// Couldn't crop the region (requested region is outside the largest
// possible region). Throw an exception.
// store what we tried to request (prior to trying to crop)
inputPtr1->SetRequestedRegion( inputRequestedRegion1 );
// build an exception
itk::InvalidRequestedRegionError e(__FILE__, __LINE__);
itk::OStringStream msg;
msg << this->GetNameOfClass()
<< "::GenerateInputRequestedRegion()";
e.SetLocation(msg.str().c_str());
e.SetDescription("Requested region is (at least partially) outside the largest possible region of image 1.");
e.SetDataObject(inputPtr1);
throw e;
}
if ( inputRequestedRegion2.Crop(inputPtr2->GetLargestPossibleRegion()))
{
inputPtr2->SetRequestedRegion( inputRequestedRegion2 );
}
else
{
// Couldn't crop the region (requested region is outside the largest
// possible region). Throw an exception.
// store what we tried to request (prior to trying to crop)
inputPtr2->SetRequestedRegion( inputRequestedRegion2 );
// build an exception
itk::InvalidRequestedRegionError e(__FILE__, __LINE__);
itk::OStringStream msg;
msg << this->GetNameOfClass()
<< "::GenerateInputRequestedRegion()";
e.SetLocation(msg.str().c_str());
e.SetDescription("Requested region is (at least partially) outside the largest possible region of image 1.");
e.SetDataObject(inputPtr2);
throw e;
}
return;
}
/**
* ThreadedGenerateData Performs the neighborhood-wise operation
...
...
@@ -86,9 +188,9 @@ BinaryFunctorNeighborhoodImageFilter<TInputImage1, TInputImage2, TOutputImage, T
// We use dynamic_cast since inputs are stored as DataObjects. The
// ImageToImageFilter::GetInput(int) always returns a pointer to a
// TInputImage1 so it cannot be used for the second input.
Input1ImagePointer inputPtr1
Input1Image
Const
Pointer inputPtr1
= dynamic_cast<const TInputImage1*>(ProcessObjectType::GetInput(0));
Input2ImagePointer inputPtr2
Input2Image
Const
Pointer inputPtr2
= dynamic_cast<const TInputImage2*>(ProcessObjectType::GetInput(1));
OutputImagePointer outputPtr = this->GetOutput(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