本文整理汇总了C++中inputimagetype::Pointer::SetPixel方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::SetPixel方法的具体用法?C++ Pointer::SetPixel怎么用?C++ Pointer::SetPixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inputimagetype::Pointer
的用法示例。
在下文中一共展示了Pointer::SetPixel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_retinalLayerSegButton_clicked
void segmentation::on_retinalLayerSegButton_clicked()
{
fstream fin1, fin7, fin11, fin12;
char* s1Txt = ("../data/ped/txt/15715_1.txt");//s1.txt
char* s7Txt = ("../data/ped/txt/15715_7.txt");
char* s11Txt = ("../data/ped/txt/15715_11.txt");
char* s12Txt = ("../data/ped/txt/15715_12.txt");
//这样开辟内存容易出现堆栈溢出问题, 选择new & delete
//int s1[64][512], s7[64][512], s11[64][512], s12[64][512];
int (*s1)[512] = new int [64][512];
int (*s7)[512] = new int [64][512];
int (*s11)[512] = new int [64][512];
int (*s12)[512] = new int [64][512];
fin1.open(s1Txt, ios::in);
fin7.open(s7Txt, ios::in);
fin11.open(s11Txt, ios::in);
fin12.open(s12Txt, ios::in);
for(int z=0; z<64; z++)
{
for(int x=0; x<512; x++)
{
fin1>>s1[z][x];
fin7>>s7[z][x];
fin11>>s11[z][x];
fin12>>s12[z][x];
}
}
fin1.close();
fin7.close();
fin11.close();
fin12.close();
typedef itk::Image<unsigned short,3>InputImageType;
typedef itk::Image<unsigned short,3>OutputImageType;
InputImageType::Pointer inputImage = InputImageType::New();
InputImageType::Pointer outputImage = InputImageType::New();
typedef itk::ImageFileReader<InputImageType>ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(inputFileName);
reader->Update();
inputImage = reader->GetOutput();
InputImageType::IndexType voxelIndex;
InputImageType::SizeType imgSize = inputImage->GetLargestPossibleRegion().GetSize();
OutputImageType::IndexType index;
index[0]=0;
index[1]=0;
index[2]=0;
OutputImageType::SizeType size;
size[0]=imgSize[0];
size[1]=imgSize[1];
size[2]=imgSize[2];
//create a region for enhance result
OutputImageType::RegionType region;
region.SetIndex(index);
region.SetSize(size);
outputImage->SetRegions(region);
outputImage->Allocate();
//make four surfaces into a MHD file
for(int z = 0; z < imgSize[2]; z++)
for(int y = 0; y < imgSize[1]; y++)
for(int x = 0; x < imgSize[0]; x++)
{
voxelIndex[0] = x;
voxelIndex[1] = y;
voxelIndex[2] = z;
if(y == s1[z][x])
{
inputImage->SetPixel(voxelIndex, 65535);
}
if(y == s7[z][x])
{
inputImage->SetPixel(voxelIndex, 65535);
}
if(y == s11[z][x])
{
inputImage->SetPixel(voxelIndex, 65535);
}
if(y == s12[z][x])
{
inputImage->SetPixel(voxelIndex, 65535);
}
}
delete []s1;//释放内存
delete []s7;
delete []s11;
delete []s12;
//文件前缀名
filePrefix = inputFileName;//char* to string
filePrefix = filePrefix.substr(0, filePrefix.length() - 4);
filePrefix = filePrefix + "_layerSeg.mhd";
strcpy(outputFileName, filePrefix.c_str());//string to char*
typedef itk::ImageFileWriter<OutputImageType>WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(outputFileName);
writer->SetInput(inputImage);
writer->Update();
emit returnOutputFileName(outputFileName);//发出信号
}