当前位置:网站首页>itk 多分辨率图像 itk::RecursiveMultiResolutionPyramidImageFilter
itk 多分辨率图像 itk::RecursiveMultiResolutionPyramidImageFilter
2022-06-12 12:25:00 【4月16!】
itk::RecursiveMultiResolutionPyramidImageFilter
最后获得多个分辨率图像:

#include "itkImage.h"
#include "itkImageFileWriter.h"
#include "itkRescaleIntensityImageFilter.h"
#include "itkRecursiveMultiResolutionPyramidImageFilter.h"
using UnsignedCharImageType = itk::Image<unsigned char, 2>;
static void
CreateImage(UnsignedCharImageType::Pointer image);
int
main(int, char *[])
{
UnsignedCharImageType::Pointer image = UnsignedCharImageType::New();
CreateImage(image);
using FloatImageType = itk::Image<float, 2>;
unsigned int numberOfLevels = 4;
using RecursiveMultiResolutionPyramidImageFilterType =
itk::RecursiveMultiResolutionPyramidImageFilter<UnsignedCharImageType, FloatImageType>;
RecursiveMultiResolutionPyramidImageFilterType::Pointer recursiveMultiResolutionPyramidImageFilter =
RecursiveMultiResolutionPyramidImageFilterType::New();
recursiveMultiResolutionPyramidImageFilter->SetInput(image);
recursiveMultiResolutionPyramidImageFilter->SetNumberOfLevels(numberOfLevels);
recursiveMultiResolutionPyramidImageFilter->Update();
// This outputs the levels (0 is the lowest resolution)
for (unsigned int i = 0; i < numberOfLevels; ++i)
{
// Scale so we can write to a PNG
using RescaleFilterType = itk::RescaleIntensityImageFilter<FloatImageType, UnsignedCharImageType>;
RescaleFilterType::Pointer rescaleFilter = RescaleFilterType::New();
rescaleFilter->SetInput(recursiveMultiResolutionPyramidImageFilter->GetOutput(i));
rescaleFilter->SetOutputMinimum(0);
rescaleFilter->SetOutputMaximum(255);
rescaleFilter->Update();
using FileWriterType = itk::ImageFileWriter<UnsignedCharImageType>;
FileWriterType::Pointer writer = FileWriterType::New();
std::stringstream ss;
ss << "output_" << i << ".png";
std::cout << "Writing " << ss.str() << std::endl;
writer->SetFileName(ss.str());
writer->SetInput(rescaleFilter->GetOutput());
writer->Update();
}
return EXIT_SUCCESS;
}
void
CreateImage(UnsignedCharImageType::Pointer image)
{
// Create a black image with a white region
UnsignedCharImageType::IndexType start;
start.Fill(0);
UnsignedCharImageType::SizeType size;
size.Fill(200);
UnsignedCharImageType::RegionType region(start, size);
image->SetRegions(region);
image->Allocate();
image->FillBuffer(0);
// Make a square
for (unsigned int r = 20; r < 80; r++)
{
for (unsigned int c = 30; c < 100; c++)
{
UnsignedCharImageType::IndexType pixelIndex;
pixelIndex[0] = r;
pixelIndex[1] = c;
image->SetPixel(pixelIndex, 255);
}
}
}
边栏推荐
猜你喜欢

开源项目-(ERP+酒店+电商)后台管理系统

Bat interview & advanced, get interview materials at the end of the text

Rust语言学习

Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference

vant 标签栏+上拉加载+下拉刷新demo van-tabs+van-pull-refresh+van-list demo

点云配准--gicp原理与其在pcl中的使用

元宇宙是短炒,还是未来趋势?

Influxdb2.x benchmark tool - influxdb comparisons

Promise knowledge

MySQL 分区表介绍与测试
随机推荐
In navigation, the solution of adding borders to affect the layout
The difference between bind, call and apply, and the encapsulation of bind()
sublime_ Textuse
NewOJ Week 10题解
The direction of this
AND THE BIT GOES DOWN: REVISITING THE QUANTIZATION OF NEURAL NETWORKS
【Leetcode】199. Right view of binary tree
Differences between server-side rendering and client-side rendering (advantages and disadvantages)
The advantages of saving pointers when saving objects with vector and the use of reserve
Promise understanding has used promise to realize picture preloading (sequential loading)
22年gdcpc广东省赛记录
NDT配准原理
C语言进阶篇——浮点型在内存中的存储
Kotlin扩展函数实现原理
ELK搭建指南
for in 与Object.keys()的区别
单页面开发与多页面开发的优缺点
宏编译 预处理头 WIN32_LEAN_AND_MEAN
MySQL review
导航中,添加边框影响布局的解决方法