Giter Club home page Giter Club logo

Comments (1)

hjmjohnson avatar hjmjohnson commented on July 29, 2024

//Author \Hans J. Johnson
// Test program to find bug in periodic boundary conditions.

#include <rtkForwardDifferenceGradientImageFilter.h>
#include <rtkBackwardDifferenceDivergenceImageFilter.h>

const size_t IM2DSIZE=3;

template
void DumpImage(IMTYPE out)
{
typename IMTYPE::ObjectType::IndexType idx;
std::cout << "==========================================" << std::endl;
for(size_t k = 0; k < IM2DSIZE; ++k)
{
idx[2] = k;
for(size_t j = 0; j < IM2DSIZE; ++j)
{
idx[1]=j;
for(size_t i = 0; i< IM2DSIZE; ++i)
{
idx[0]=i;
std::cout.width(16);
std::cout.fill(' ');
std::cout << std::right << out->GetPixel(idx);
}
std::cout << std::endl;
}
std::cout << ". - . - . - . - . - . - . - . - . - . - . " << std::endl;
}
std::cout << "==========================================" << std::endl;
}

int main( int argc, char * argv[])
{
typedef itk::Image<float,3> Image2D;
Image2D::Pointer im2 = Image2D::New();
Image2D::RegionType region;
Image2D::RegionType::SizeType size;
size.Fill(IM2DSIZE);
region.SetSize(size);
im2->SetRegions(region);
im2->Allocate(true);
Image2D::IndexType idx;
idx.Fill(IM2DSIZE/2);
idx.Fill(0);
im2->SetPixel(idx,1.0F);
//typedef itk::GradientImageFilter GradientType;
typedef rtk::ForwardDifferenceGradientImageFilter GradientType;
GradientType::Pointer grad = GradientType::New();
grad->SetInput(im2);
typedef itk::PeriodicBoundaryCondition FloatBoundaryType;
grad->OverrideBoundaryCondition( new FloatBoundaryType );
grad->Update();
GradientType::OutputImageType::Pointer gradIm = grad->GetOutput();
//typedef itk::DivergenceImageFilterGradientType::OutputImageType DivergenceType;
typedef rtk::BackwardDifferenceDivergenceImageFilterGradientType::OutputImageType DivergenceType;
DivergenceType::Pointer div = DivergenceType::New();
div->SetInput(gradIm);
typedef itk::PeriodicBoundaryConditionGradientType::OutputImageType CVBoundaryType;
div->OverrideBoundaryCondition(new CVBoundaryType);
div->Update();
DivergenceType::OutputImageType::Pointer divIm = div->GetOutput();
std::cout << "Intensity Image" << std::endl;
DumpImage(im2);
DumpImage(gradIm);
DumpImage(divIm);

return 0;
}

from rtk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.