16 #include "vtkImageData.h" 17 #include "vtkMetaImageReader.h" 18 #include "vtkLookupTable.h" 19 #include "vtkImageMapToColors.h" 20 #include <vtkImageChangeInformation.h> 25 #include <vtkImageExtractComponents.h> 26 #include <vtkImageAppendComponents.h> 27 #include <vtkImageLuminance.h> 43 std::vector<PropertyPtr> retval;
53 "Select a 3D image file to stream from",
55 QStringList() <<
profile()->getSessionRootFolder(),
58 retval->setGroup(
"File");
65 bool defaultValue =
false;
67 "Create two streams, the second one a dummy color image",
69 retval->setAdvanced(
true);
70 retval->setGroup(
"File");
77 retval[
"--type"] =
"MHDFile";
80 retval[
"--secondary"] =
"1";
87 retval <<
"--filename: name of image file to stream from ";
88 retval <<
"--secondary: Create two streams, the second one a dummy color image";
105 lut->SetNumberOfTableValues(numberOfTableValues);
106 lut->SetTableRange(0, numberOfTableValues - 1);
107 lut->SetSaturationRange(0, 0.5);
108 lut->SetHueRange(0, 1);
109 lut->SetValueRange(0, 1);
117 mapper->SetInputData(input);
118 mapper->SetLookupTable(lut);
126 int numberOfTableValues = 256;
136 QString colorFormat =
"R";
137 if (source->GetNumberOfScalarComponents() == 3)
141 splitterRGB->SetInputData(source);
142 splitterRGB->SetComponents(0, 1, 2);
144 merger->AddInputConnection(splitterRGB->GetOutputPort());
146 splitterA->SetInputData(source);
147 splitterA->SetComponents(0);
148 merger->AddInputConnection(splitterA->GetOutputPort());
152 colorFormat =
"RGBA";
154 else if (source->GetNumberOfScalarComponents() == 4)
157 colorFormat =
"RGBA";
159 else if (source->GetNumberOfScalarComponents() == 1)
165 retval.
mRawUid = QString(
"%1 [%2]").arg(QFileInfo(filename).completeBaseName()).arg(colorFormat);
174 QString colorFormat =
"R";
175 if (source->GetNumberOfScalarComponents() == 3)
177 vtkSmartPointer < vtkImageLuminance > luminance = vtkSmartPointer < vtkImageLuminance > ::New();
178 luminance->SetInputData(source);
184 else if (source->GetNumberOfScalarComponents() == 4)
187 colorFormat =
"RGBA";
189 else if (source->GetNumberOfScalarComponents() == 1)
195 retval.
mRawUid = QString(
"uchar %1[%2]").arg(QFileInfo(filename).completeBaseName()).arg(colorFormat);
210 image->setAcquisitionTime(QDateTime::currentDateTime());
211 package->mImage = image;
217 mUseSecondaryStream(false),
218 mPrimaryDataSource(),
219 mSecondaryDataSource()
229 vtkImageDataPtr DummyImageStreamer::internalLoadImage(QString filename)
235 reader->ReleaseDataFlagOn();
241 zeroer->SetInputConnection(reader->GetOutputPort());
242 zeroer->SetOutputOrigin(0, 0, 0);
243 CX_LOG_DEBUG() <<
"DummyImageStreamer::internalLoadImage. Initialized vtkImageChangeInformation";
245 CX_LOG_DEBUG() <<
"DummyImageStreamer::internalLoadImage. updated VTK pipeline";
249 std::cout <<
"DummyImageStreamer: Initialized with source file: " << getFileName().toStdString() << std::endl;
251 std::cout <<
"DummyImageStreamer: Failed to initialize with source file: " << getFileName().toStdString() << std::endl;
255 QString DummyImageStreamer::getFileName()
270 if (!this->shouldSetupSecondaryDataSource())
274 std::cout <<
"DummyImageStreamer: Initialized secondary data with uid=" << mSecondaryDataSource.
mRawUid << std::endl;
281 QString filename = arguments[
"filename"];
282 bool secondary = arguments.count(
"secondary") ?
true :
false;
288 mUseSecondaryStream = secondaryStream;
289 mFilename = filename;
296 this->createTestDataSource(source);
297 this->setSendOnce(sendonce);
306 reportError(
"DummyImageStreamer: Failed to start streaming: Not initialized.");
323 vtkSmartPointer<vtkImageData> DummyImageStreamer::hasSecondaryData()
328 void DummyImageStreamer::sendTestDataFrames()
333 if(!this->hasSecondaryData())
337 mSender->send(secondaryPackage);
340 void DummyImageStreamer::streamSlot()
345 this->sendTestDataFrames();
348 void DummyImageStreamer::setSendOnce(
bool sendonce)
350 mSendOnce = sendonce;
353 bool DummyImageStreamer::shouldSetupSecondaryDataSource()
355 return mUseSecondaryStream;
cxResource_EXPORT ProfilePtr profile()
static BoolPropertyPtr initialize(const QString &uid, QString name, QString help, bool value, QDomNode root=QDomNode())
void reportError(QString msg)
void createSendTimer(bool singleshot=false)
static PackagePtr createPackage(ImageTestData *data)
static ImageTestData initializePrimaryData(vtkImageDataPtr source, QString filename)
FilePathPropertyPtr getFilenameOption(QDomElement root)
void setSendInterval(int milliseconds)
how often an image should be sent (in milliseconds)
vtkLookupTablePtr createLookupTable(int numberOfTableValues)
vtkImageDataPtr mImageData
virtual bool isStreaming()
boost::shared_ptr< class Image > ImagePtr
virtual std::vector< PropertyPtr > getSettings(QDomElement root)
vtkSmartPointer< vtkImageChangeInformation > vtkImageChangeInformationPtr
virtual void initialize(QString filename, bool secondaryStream, bool sendonce=false)
cstring_cast_Placeholder cstring_cast(const T &val)
virtual QString getType()
vtkSmartPointer< class vtkImageMapToColors > vtkImageMapToColorsPtr
vtkSmartPointer< class vtkMetaImageReader > vtkMetaImageReaderPtr
std::map< QString, QString > StringMap
QStringList getArgumentDescription()
vtkSmartPointer< class vtkImageAppendComponents > vtkImageAppendComponentsPtr
boost::shared_ptr< class BoolPropertyBase > BoolPropertyBasePtr
virtual void startStreaming(SenderPtr sender)
virtual void stopStreaming()
void setInitialized(bool initialized)
vtkSmartPointer< class vtkLookupTable > vtkLookupTablePtr
vtkImageDataPtr applyLUTToImage(vtkImageDataPtr input, vtkLookupTablePtr lut)
virtual QStringList getArgumentDescription()
static FilePathPropertyPtr initialize(const QString &uid, QString name, QString help, QString value, QStringList paths, QDomNode root=QDomNode())
vtkSmartPointer< class vtkImageExtractComponents > vtkImageExtractComponentsPtr
boost::shared_ptr< struct Package > PackagePtr
boost::shared_ptr< class SplitFramesContainer > mDataSource
vtkImageDataPtr convertToTestColorImage(vtkImageDataPtr image)
boost::shared_ptr< class FilePathProperty > FilePathPropertyPtr
StringMap convertToCommandLineArguments(QDomElement root)
boost::shared_ptr< class BoolProperty > BoolPropertyPtr
boost::shared_ptr< Sender > SenderPtr
static ImageTestData initializeSecondaryData(vtkImageDataPtr source, QString filename)
virtual void initialize(StringMap arguments)
BoolPropertyBasePtr getSecondaryOption(QDomElement root)
int getSendInterval() const
how often an image should be sent (in milliseconds)
Namespace for all CustusX production code.