}
//--------------------------------------------------------------------
+
+//--------------------------------------------------------------------
bool clitk::DicomRTStruct2ImageFilter::ImageInfoIsSet() const
{
return mSize.size() && mSpacing.size() && mOrigin.size();
}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+void clitk::DicomRTStruct2ImageFilter::SetWriteOutputFlag(bool b)
+{
+ mWriteOutput = b;
+}
+//--------------------------------------------------------------------
+
//--------------------------------------------------------------------
void clitk::DicomRTStruct2ImageFilter::SetROI(clitk::DicomRT_ROI * roi)
//--------------------------------------------------------------------
+//--------------------------------------------------------------------
+void clitk::DicomRTStruct2ImageFilter::SetImage(vvImage::Pointer image)
+{
+ if (image->GetNumberOfDimensions() != 3) {
+ std::cerr << "Error. Please provide a 3D image." << std::endl;
+ exit(0);
+ }
+ mSpacing.resize(3);
+ mOrigin.resize(3);
+ mSize.resize(3);
+ for(unsigned int i=0; i<3; i++) {
+ mSpacing[i] = image->GetSpacing()[i];
+ mOrigin[i] = image->GetOrigin()[i];
+ mSize[i] = image->GetSize()[i];
+ }
+}
+//--------------------------------------------------------------------
+
+
//--------------------------------------------------------------------
void clitk::DicomRTStruct2ImageFilter::SetImageFilename(std::string f)
{
}
//--------------------------------------------------------------------
+
+//--------------------------------------------------------------------
void clitk::DicomRTStruct2ImageFilter::SetOutputOrigin(const double* origin)
{
std::copy(origin,origin+3,std::back_inserter(mOrigin));
}
+//--------------------------------------------------------------------
+
+
//--------------------------------------------------------------------
void clitk::DicomRTStruct2ImageFilter::SetOutputSpacing(const double* spacing)
{
std::copy(spacing,spacing+3,std::back_inserter(mSpacing));
}
+//--------------------------------------------------------------------
+
+
//--------------------------------------------------------------------
void clitk::DicomRTStruct2ImageFilter::SetOutputSize(const unsigned long* size)
{
std::copy(size,size+3,std::back_inserter(mSize));
}
+//--------------------------------------------------------------------
+
//--------------------------------------------------------------------
void clitk::DicomRTStruct2ImageFilter::Update()
void SetROI(clitk::DicomRT_ROI * roi);
///This is used to create a mask with the same characteristics as an input image
+ void SetImage(vvImage::Pointer image);
void SetImageFilename(std::string s);
void SetOutputOrigin(const double* origin);
void SetOutputSpacing(const double* spacing);
vtkImageData * GetOutput();
template <int Dimension> typename itk::Image<unsigned char,Dimension>::ConstPointer GetITKOutput();
void SetCropMaskEnabled(bool b);
+ void SetWriteOutputFlag(bool b);
protected:
bool ImageInfoIsSet() const;
if (args_info.roi_arg != -1) {
filter.SetROI(s->GetROIFromROINumber(args_info.roi_arg));
filter.SetOutputImageFilename(args_info.output_arg);
- filter.Update();
+ filter.Update();
}
else {
clitk::DicomRT_StructureSet::ROIConstIteratorType iter;
// vv
#include "vvToolROIManager.h"
#include "vvImageReader.h"
+#include "vvImageWriter.h"
#include "vvROIActor.h"
#include "vvSlicer.h"
#include "vvROIActor.h"
#include "vvStructSelector.h"
#include "vvToolManager.h"
+// clitk
+#include "clitkDicomRTStruct2ImageFilter.h"
+#include "clitkDicomRT_StructureSet.h"
+
// Qt
#include <QFileDialog>
#include <QMessageBox>
mGroupBoxROI->setEnabled(false);
// Temporary disable "Load dicom" button
- frame_4->hide();
+ // frame_4->hide();
// Set default LUT
mDefaultLUTColor = vtkSmartPointer<vtkLookupTable>::New();
void vvToolROIManager::OpenBinaryImage()
{
// Open images
- QString Extensions = "Images files ( *.mha *.mhd *.hdr *.his)";
+ QString Extensions = "Images or Dicom-Struct files ( *.mha *.mhd *.hdr *.his *.dcm RS*)";
Extensions += ";;All Files (*)";
QStringList filename =
QFileDialog::getOpenFileNames(this,tr("Open binary image"),
mMainWindowBase->GetInputPathName(),Extensions);
- OpenBinaryImage(filename);
+ if (filename.size() > 1) OpenBinaryImage(filename);
+ if (filename.size() == 0) return;
+
}
//------------------------------------------------------------------------------
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
reader.SetSelectedItems(selector.getSelectedItems());
reader.SetImage(mCurrentSlicerManager->GetImage());
- reader.Update();
+ // reader.Update();
+
+ // Read and display information
+ clitk::DicomRT_StructureSet::Pointer s = clitk::DicomRT_StructureSet::New();
+ s->Read(file.toStdString());
+ s->Print(std::cout);
+
+ // FIXME -> selection
+
+ DD("here");
+ clitk::DicomRTStruct2ImageFilter filter;
+ filter.SetCropMaskEnabled(true); // FIXME
+ filter.SetImage(mCurrentImage); // Used FIXME -> change to set IMAGE
+ filter.SetROI(s->GetROIFromROINumber(1)); // FIXME selection
+ filter.SetWriteOutputFlag(false);
+ filter.Update();
+
+ DD("debug");
+ typedef itk::Image<unsigned char, 3> ImageType;
+ typedef itk::VTKImageToImageFilter<ImageType> ConnectorType;
+ ConnectorType::Pointer connector = ConnectorType::New();
+ connector->SetInput(filter.GetOutput());
+ connector->Update();
+ clitk::writeImage<ImageType>(connector->GetOutput(), "toto.mha");
+
+ // Get image
+ DD("filter done");
+ vvImage::Pointer binaryImage = vvImage::New();
+ binaryImage->AddVtkImage(filter.GetOutput());
+
+ // DEBUG write image
+ DD("write debug");
+ vvImageWriter::Pointer writer = vvImageWriter::New();
+ writer->SetOutputFileName("bidon.mha");
+ writer->SetInput(binaryImage);
+ writer->Update();
+
+ // Add to gui
+ DD("gui");
+ AddImage(binaryImage, file.toStdString(), mBackgroundValueSpinBox->value(),
+ (!mBGModeCheckBox->isChecked()));
+ mOpenedBinaryImageFilenames.push_back(file);
// std::vector<vvMesh::Pointer> contours=reader.GetOutput();
// for (std::vector<vvMesh::Pointer>::iterator i=contours.begin();