使用高斯核进行一维卷积
我的目标是计算 2D 图像的每一行(在 x 方向) 按照 Cory 的提示后,我尝试使用“ConvolutionImageFilter”,并使用我之前计算的高斯值制作内核。 我查看了这个示例(http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/ConvolutionImageFilter),我的问题是如何将高斯滤波器的值包含到内核中,我尝试使用代码下面它编译了,但当我更新卷积过滤器时,执行似乎没有结束……因此,我认为我做错了什么。我的代码在下面,并不是那么多,如果有人可以提供一些帮助,我将非常感激!!!!
typedef itk::ConvolutionImageFilter <ImageType> ConvFilterType;
ImageType::Pointer kernel = ImageType::New();
CreateKernel(kernel, Gaussian , 256);
//Convolve image with kernel
ConvFilterType::Pointer convolutionFilter = ConvFilterType::New();
convolutionFilter->SetInput(Li_itk);
convolutionFilter->SetImageKernelInput(kernel);
convolutionFilter->Update();
void Reg_image_v2::CreateKernel(Reg_image_v2::ImageType::Pointer kernel, double *Gaussian, unsigned int width) {
ImageType::IndexType start;
start.Fill(0);
ImageType::SizeType size;
size[0] = width;
size[1] = 1;
ImageType::RegionType region;
region.SetSize(size);
region.SetIndex(start);
kernel->SetRegions(region);
kernel->Allocate();
ImageType::IndexType pixelIndex;
for (int i = 0 ; i < width ; i ++){
pixelIndex[0] = i ;
pixelIndex[1] = 0 ;
kernel->SetPixel(pixelIndex,Gaussian[i]);
}
itk::ImageRegionIterator<ImageType> imageIterator(kernel, region);
while(!imageIterator.IsAtEnd())
{
//imageIterator.Set??
++imageIterator; //operator++ increments the iterator one position in the positive direction
}
} // end createKernel
安东尼奥
My goal is to calculate the calculation in each row of a 2D-image ( in the x-direction)
After following the tip from Cory I am trying to use the ‘ConvolutionImageFilter’, and make a kernel with the Gaussian values I calculate before.
I took a look to this example (http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/ConvolutionImageFilter) and my question is how to include the values of the Gaussian filter to the kernel, I tried wit the code below and it compiles, but it seems the execution has no end when I update the convolutionFilter… Because of that I think that I am doing something wrong. My code is below and is not so much, if some can give some help I would appreciate that really a lot !!!!.
typedef itk::ConvolutionImageFilter <ImageType> ConvFilterType;
ImageType::Pointer kernel = ImageType::New();
CreateKernel(kernel, Gaussian , 256);
//Convolve image with kernel
ConvFilterType::Pointer convolutionFilter = ConvFilterType::New();
convolutionFilter->SetInput(Li_itk);
convolutionFilter->SetImageKernelInput(kernel);
convolutionFilter->Update();
void Reg_image_v2::CreateKernel(Reg_image_v2::ImageType::Pointer kernel, double *Gaussian, unsigned int width) {
ImageType::IndexType start;
start.Fill(0);
ImageType::SizeType size;
size[0] = width;
size[1] = 1;
ImageType::RegionType region;
region.SetSize(size);
region.SetIndex(start);
kernel->SetRegions(region);
kernel->Allocate();
ImageType::IndexType pixelIndex;
for (int i = 0 ; i < width ; i ++){
pixelIndex[0] = i ;
pixelIndex[1] = 0 ;
kernel->SetPixel(pixelIndex,Gaussian[i]);
}
itk::ImageRegionIterator<ImageType> imageIterator(kernel, region);
while(!imageIterator.IsAtEnd())
{
//imageIterator.Set??
++imageIterator; //operator++ increments the iterator one position in the positive direction
}
} // end createKernel
Antonio
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你看过 itkGaussianOperator 吗?
http://www.itk.org/Wiki/ITK/Examples/Operators/GaussianOperator
Have you looked at the itkGaussianOperator?
http://www.itk.org/Wiki/ITK/Examples/Operators/GaussianOperator