insightsoftwareconsortium / itkgrowcut Goto Github PK
View Code? Open in Web Editor NEWITKGrowCut is a remote module for ITK. It segments a 3D image from user-provided foreground and background seeds.
License: Apache License 2.0
ITKGrowCut is a remote module for ITK. It segments a 3D image from user-provided foreground and background seeds.
License: Apache License 2.0
The code in Slicer has been refactored and improved, compared to the original one from which current implementation is derived.
I have successful run the ITKGrowCut
with the provided data, and the result is good.
Then, I test the ITKGrowCut
with my own data, and the result is:
The shown figure is: original image (left), seed point for object and background (middle), and result from grow cut (right).
The zoom in seed point and grow cut result is:
We can see that the grow cut result is poor, which just copy the seed point.
In the provided demo data, many seeds is provided. But in my data, I only provide very few seed point, where pixel of 1 indicates ventricle and pixel of 2 indicates the background. Is the poor grow cut result caused by the few seed points?
I can compile ITKGrowCut, and successfully run it. But the result is not good.
In the above figure, the left is the result from ITKGrowCut and the right is the result from geodesic segmentation.
The result from ITKGrowCut is poor, and I want to know:
how to set the seed point for background? I can only set seed point for foreground by: fgcFilter->SetSeedImage(foregroundMaskReader->GetOutput());
.
what should be the image for seed point? The pixel of none seed point should be 0, what's the value for the pixel of seed point? 1 or 255?
Hi, I used ITKGrowCut test code with my data, and
it worked, but very slow. My data_size is 512x512x785, and i need take 3-4 minutes to process it. May i ask you how to accelerate it?
my test code is:
#include <iostream>
#include <string>
#include "itkFastGrowCut.h"
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
int main(int argc, char* argv[])
{
const char* inputImage = "E:\\HCM\\DATASET\\itkgrwocut\\image.nii.gz";
const char* seedsImage = "E:\\HCM\\DATASET\\itkgrwocut\\seed.nii.gz";
const char* noisyLabels = "E:\\HCM\\DATASET\\itkgrwocut\\label.nii.gz";
constexpr unsigned int Dimension = 3;
using PixelType = short;
using ImageType = itk::Image<PixelType, Dimension>;
using LabelType = itk::Image<unsigned char, Dimension>;
using FGCType = itk::FastGrowCut<ImageType, LabelType>;
FGCType::Pointer fgcFilter = FGCType::New();
// Read the images
typedef itk::ImageFileReader<ImageType> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(inputImage);
reader->Update();
ImageType::Pointer image = reader->GetOutput();
typedef itk::ImageFileReader<LabelType> ReaderType2;
ReaderType2::Pointer reader2 = ReaderType2::New();
reader2->SetFileName(seedsImage);
reader2->Update();
LabelType::Pointer seeds = reader2->GetOutput();
// Filter the original, possibly noisy image
fgcFilter->SetInput(image);
fgcFilter->SetSeedImage(seeds);
fgcFilter->Update();
using WriterType = itk::ImageFileWriter<LabelType>;
WriterType::Pointer writer = WriterType::New();
writer->SetInput(fgcFilter->GetOutput());
writer->SetFileName(noisyLabels);
writer->Update();
std::cout << "Test finished." << std::endl;
return EXIT_SUCCESS;
}
the inputimage and seed are:
I want to use ITKGrowCut
in my project, but there are some trouble to build it.
Firstly, I can successfully compile it. But when I include the itkFastGrowCut.h
, a bug is reported:
1. can not open "itkPrintHelper.h"
2. missing type specifier- int assumed. Note: C++ does not support default-int
The second bug is located at: ITK_DISALLOW_COPY_AND_MOVE(FastGrowCut);
(itkFastGrowCut).
Then, I re-compile the ITK, and turn the Build_Testing
on, and more bugs are reported:
1. can not open `itkImageRegionIterator.h`
2. can not open `itkImageRegionIteratorWithIndex.h`
3. can not open `itkNumericTraits.h`
4. can not open `itkRegionOfInterestImageFilter.h`
5. can not open `GrowCutExport.h`
6. can not open `itkImageToImageFilter.h`
7. can not open `itkPrintHelper.h`
8. identifier 'LabPixelType` is not defined.
9. identifier `SrcPixelType` is not defined
...
All the above bugs is reported from GrowCut-all
project.
My environment is:
win 10
vs 2019
cmake 3.20.4
ITK: 4.13.3
If DistancePenalty is changed then all the internal distance volume would need to be recomputed from scratch. However, currently this is not happening. The result is that after an initial Update()
call, setting DistancePenalty
and calling Update()
again has no effect.
See an example here: Slicer/Slicer#6946 (review)
[277/278] Building CXX object Modules/Remote/GrowCut/test/CMakeFiles/GrowCutTestDriver.dir/itkFastGrowCutTest.cxx.o
In file included from /Users/johnsonhj/Dashboard/src/ITK/Modules/Remote/GrowCut/test/itkFastGrowCutTest.cxx:19:
In file included from /Users/johnsonhj/Dashboard/src/ITK/Modules/Remote/GrowCut/include/itkFastGrowCut.h:197:
/Users/johnsonhj/Dashboard/src/ITK/Modules/Remote/GrowCut/include/itkFastGrowCut.hxx:99:17: warning: declaration shadows a field of 'FastGrowCut<TInputImage, TLabelImage, TMaskImage>' [-Wshadow]
NodeIndexType m_DimX = region.GetSize(0);
^
/Users/johnsonhj/Dashboard/src/ITK/Modules/Remote/GrowCut/include/itkFastGrowCut.h:181:17: note: previous declaration is here
NodeIndexType m_DimX;
^
In file included from /Users/johnsonhj/Dashboard/src/ITK/Modules/Remote/GrowCut/test/itkFastGrowCutTest.cxx:19:
In file included from /Users/johnsonhj/Dashboard/src/ITK/Modules/Remote/GrowCut/include/itkFastGrowCut.h:197:
/Users/johnsonhj/Dashboard/src/ITK/Modules/Remote/GrowCut/include/itkFastGrowCut.hxx:100:17: warning: declaration shadows a field of 'FastGrowCut<TInputImage, TLabelImage, TMaskImage>' [-Wshadow]
NodeIndexType m_DimY = region.GetSize(1);
^
/Users/johnsonhj/Dashboard/src/ITK/Modules/Remote/GrowCut/include/itkFastGrowCut.h:182:17: note: previous declaration is here
NodeIndexType m_DimY;
^
In file included from /Users/johnsonhj/Dashboard/src/ITK/Modules/Remote/GrowCut/test/itkFastGrowCutTest.cxx:19:
In file included from /Users/johnsonhj/Dashboard/src/ITK/Modules/Remote/GrowCut/include/itkFastGrowCut.h:197:
/Users/johnsonhj/Dashboard/src/ITK/Modules/Remote/GrowCut/include/itkFastGrowCut.hxx:101:17: warning: declaration shadows a field of 'FastGrowCut<TInputImage, TLabelImage, TMaskImage>' [-Wshadow]
NodeIndexType m_DimZ = region.GetSize(2);
^
/Users/johnsonhj/Dashboard/src/ITK/Modules/Remote/GrowCut/include/itkFastGrowCut.h:183:17: note: previous declaration is here
NodeIndexType m_DimZ;
^
In file included from /Users/johnsonhj/Dashboard/src/ITK/Modules/Remote/GrowCut/test/itkFastGrowCutTest.cxx:19:
In file included from /Users/johnsonhj/Dashboard/src/ITK/Modules/Remote/GrowCut/include/itkFastGrowCut.h:197:
/Users/johnsonhj/Dashboard/src/ITK/Modules/Remote/GrowCut/include/itkFastGrowCut.hxx:295:24: warning: declaration shadows a local variable [-Wshadow]
LabelPixelType * resultLabelVolumePtr = resultLabelVolume->GetBufferPointer();
^
/Users/johnsonhj/Dashboard/src/ITK/Modules/Remote/GrowCut/include/itkFastGrowCut.hxx:288:30: note: previous declaration is here
LabelPixelType * resultLabelVolumePtr = resultLabelVolume->GetBufferPointer();
^
/Users/johnsonhj/Dashboard/src/ITK/Modules/Remote/GrowCut/include/itkFastGrowCut.hxx:382:16: warning: unused variable 'compareTolerance' [-Wunused-variable]
const double compareTolerance = (spacing[0] + spacing[1] + spacing[2]) / 3.0 * 0.01;
^
/Users/johnsonhj/Dashboard/src/ITK/Modules/Remote/GrowCut/include/itkFastGrowCut.hxx:377:14: warning: unused variable 'seedImage' [-Wunused-variable]
auto seedImage = this->GetSeedImage();
^
/Users/johnsonhj/Dashboard/src/ITK/Modules/Remote/GrowCut/include/itkFastGrowCut.h:69:15: note: in instantiation of member function 'itk::FastGrowCut<itk::Image<short, 3>, itk::Image<unsigned char, 3>, itk::Image<unsigned char, 3> >::GenerateData' requested here
itkNewMacro(Self);
^
/Users/johnsonhj/Dashboard/src/ITK/Modules/Remote/GrowCut/test/itkFastGrowCutTest.cxx:78:41: note: in instantiation of member function 'itk::FastGrowCut<itk::Image<short, 3>, itk::Image<unsigned char, 3>, itk::Image<unsigned char, 3> >::New' requested here
FGCType::Pointer fgcFilter = FGCType::New();
^
6 warnings generated.
[278/278] Linking CXX executable bin/GrowCutTestDriver
When building the ITKGrowCut
project, a bug is reported if BUILD_TESTING
is ON
:
can not find Generating test/GrowCutHeaderTest1.cxx
hi,i want use ITKGrowCut in my project,i modify the test code,the program like this:
#include <iostream>
#include "itkFastGrowCut.h"
#include "itkCommand.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkMedianImageFilter.h"
#include "itkTestingMacros.h"
int main(int argc, char* argv[])
{
const char* inputImage = "D:\\roi_image_sitk.nii.gz";
const char* seedsImage = "D:\\seedsimagesitk.nii.gz";
const char* noisyLabels = "growcut.nii.gz";
constexpr unsigned int Dimension = 3;
using PixelType = short;
using ImageType = itk::Image<PixelType, Dimension>;
using LabelType = itk::Image<unsigned char, Dimension>;
using FGCType = itk::FastGrowCut<ImageType, LabelType>;
FGCType::Pointer fgcFilter = FGCType::New();
// Read the images
typedef itk::ImageFileReader<ImageType> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(inputImage);
reader->Update();
ImageType::Pointer image = reader->GetOutput();
typedef itk::ImageFileReader<LabelType> ReaderType2;
ReaderType2::Pointer reader2 = ReaderType2::New();
reader2->SetFileName(seedsImage);
reader2->Update();
LabelType::Pointer seeds = reader2->GetOutput();
// Filter the original, possibly noisy image
fgcFilter->SetInput(image);
fgcFilter->SetSeedImage(seeds);
fgcFilter->Update();
using WriterType = itk::ImageFileWriter<LabelType>;
WriterType::Pointer writer = WriterType::New();
writer->SetInput(fgcFilter->GetOutput());
writer->SetFileName(noisyLabels);
writer->Update();
std::cout << "Test finished." << std::endl;
return EXIT_SUCCESS;
}
image and seed mask image is this:
the program can get result,but the result is same with seedsimagesitk,don't have any binary mask image.
maybe some wrong with my input image and seed mask,can you share example how to use it?
thank you
chenjunqiang
Since ITKGrowCut
is a remote module for ITK, should I put ITKGrowCut
into to ITK/Modules/ThirdParty
or implement a GrowCut.remote.cmake
by myself?
I have directly build ITKGrowCut
, but it failed to find GrowCut
in CMake
:
find_package(GrowCut)
or
find_package(ITKGrowCut)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.