Hi Prabhu, I made some progress with your data. I hope this might help …. First of all, I am facing problems with 6.mha and 7.mha since they are out of alignment compared to the other samples. I would really recommend that you start with a set of shapes that share the same bounding box and volume size. Also it is recommended to work with isotropic voxel spacing which is not the case of your data. Second, you data is suffering from a very low resolution, that is, the voxel spacing is too large compared to the shape complexity that you are having. Hence, any blurring that will be applied to the data will eat up thin structures whose thickness only occupy couple of voxels. So I have written an itk-based command line tool (kindly see attached) that would allow you to resample your data to smaller voxel size that you can control. To test my hypothesis, I have resampled your data to 0.5 isotropic voxel spacing and applied the groom stage, kindly see the below snapshot, you can see that even if a Gaussian blurring has been applied with sigma = 2, we still preserve your shapes structure. |
Here is the result of the grooming stage with the same parameters using your original data, as you can see, think structures and even the vertebra itself is overly smoothed ... |
Hope this helps … best regards Shireen
On 07/30/2015 09:36 PM, Prabhu Teja wrote:
|
Prabhu Teja
NOTE: This message was trained as non-spam. If this is wrong, please correct the training as soon as possible. Spam Not spam Forget previous vote Prabhu Teja
|
#include <fstream> #include "itkImage.h" #include "itkIdentityTransform.h" #include "itkImageFileReader.h" #include "itkImageFileWriter.h" #include "itkResampleImageFilter.h" #include "itkNearestNeighborInterpolateImageFunction.h" int main(int argc, char* argv[]) { if(argc < 6){ std::cerr << "Usage: " << std::endl; std::cerr << argv[0] << " Input_File Output_File output_spacing_x output_spacing_y output_spacing_z\n"; return EXIT_FAILURE; } const int Dimension = 3; typedef unsigned char PixelType; typedef itk::Image<PixelType, Dimension> ImageType; typedef itk::ImageFileReader<ImageType> ReaderType; typedef itk::ImageFileWriter<ImageType> WriterType; typedef itk::IdentityTransform<double, Dimension> TransformType; typedef itk::NearestNeighborInterpolateImageFunction<ImageType, double> InterpolatorType; typedef itk::ResampleImageFilter<ImageType, ImageType> ResampleImageFilterType; std::string inputfilename = argv[1]; std::string outputfilename = argv[2]; float output_spacing_x = atof(argv[3]); float output_spacing_y = atof(argv[4]); float output_spacing_z = atof(argv[5]); // read input image std::ifstream inputfile(inputfilename.c_str()); if(inputfile.fail()){ std::cout << "Error reading file: " << inputfilename << "\n"; } ReaderType::Pointer reader = ReaderType::New(); reader->SetFileName( inputfilename ); reader ->Update(); ImageType::Pointer input = reader->GetOutput(); // WriterType::Pointer inputWriter = WriterType::New(); // inputWriter->SetFileName("input.nrrd"); // inputWriter->SetInput(input); // inputWriter->Update(); ImageType::SizeType inputSize = input->GetLargestPossibleRegion().GetSize(); std::cout << "Input size: " << inputSize << std::endl; // Resample //ImageType::SpacingType inputSpacing = input->GetSpacing(); ImageType::SpacingType outputSpacing; outputSpacing[0] = output_spacing_x; outputSpacing[1] = output_spacing_y; outputSpacing[2] = output_spacing_z; ImageType::SizeType outputSize; outputSize[0] = std::floor(input->GetSpacing()[0] * (static_cast<double>(inputSize[0]) / static_cast<double>(outputSpacing[0]))); outputSize[1] = std::floor(input->GetSpacing()[1] * (static_cast<double>(inputSize[1]) / static_cast<double>(outputSpacing[1]))); outputSize[2] = std::floor(input->GetSpacing()[2] * (static_cast<double>(inputSize[2]) / static_cast<double>(outputSpacing[2]))); outputSpacing[0] = input->GetSpacing()[0] * (static_cast<double>(inputSize[0]) / static_cast<double>(outputSize[0])); outputSpacing[1] = input->GetSpacing()[1] * (static_cast<double>(inputSize[1]) / static_cast<double>(outputSize[1])); outputSpacing[2] = input->GetSpacing()[2] * (static_cast<double>(inputSize[2]) / static_cast<double>(outputSize[2])); ResampleImageFilterType::Pointer resample = ResampleImageFilterType::New(); resample->SetInput(input); resample->SetSize(outputSize); resample->SetOutputSpacing(outputSpacing); resample->SetTransform(TransformType::New()); resample->SetInterpolator(InterpolatorType::New()); resample->SetOutputOrigin(input->GetOrigin()); resample->UpdateLargestPossibleRegion(); resample->Update(); ImageType::Pointer output = resample->GetOutput(); std::cout << "Output size: " << output->GetLargestPossibleRegion().GetSize() << std::endl; std::cout << "Writing output... " << std::endl; WriterType::Pointer outputWriter = WriterType::New(); outputWriter->SetFileName(outputfilename); outputWriter->SetInput(output); outputWriter->Update(); return EXIT_SUCCESS; }
Archive powered by MHonArc 2.6.18.