37 #include "vtkImageData.h"
38 #include "vtkMetaImageReader.h"
39 #include "vtkLookupTable.h"
40 #include "vtkImageMapToColors.h"
45 #include <vtkImageExtractComponents.h>
46 #include <vtkImageAppendComponents.h>
47 #include <vtkImageLuminance.h>
64 std::vector<PropertyPtr> retval;
74 "Select a 3D image file to stream from",
76 QStringList() <<
profile()->getSessionRootFolder(),
79 retval->setGroup(
"File");
86 bool defaultValue =
false;
88 "Create two streams, the second one a dummy color image",
90 retval->setAdvanced(
true);
91 retval->setGroup(
"File");
98 retval[
"--type"] =
"MHDFile";
101 retval[
"--secondary"] =
"1";
108 retval <<
"--filename: name of image file to stream from ";
109 retval <<
"--secondary: Create two streams, the second one a dummy color image";
126 lut->SetNumberOfTableValues(numberOfTableValues);
127 lut->SetTableRange(0, numberOfTableValues - 1);
128 lut->SetSaturationRange(0, 0.5);
129 lut->SetHueRange(0, 1);
130 lut->SetValueRange(0, 1);
138 mapper->SetInputData(input);
139 mapper->SetLookupTable(lut);
147 int numberOfTableValues = 256;
157 QString colorFormat =
"R";
158 if (source->GetNumberOfScalarComponents() == 3)
162 splitterRGB->SetInputData(source);
163 splitterRGB->SetComponents(0, 1, 2);
165 merger->AddInputConnection(splitterRGB->GetOutputPort());
167 splitterA->SetInputData(source);
168 splitterA->SetComponents(0);
169 merger->AddInputConnection(splitterA->GetOutputPort());
173 colorFormat =
"RGBA";
175 else if (source->GetNumberOfScalarComponents() == 4)
178 colorFormat =
"RGBA";
180 else if (source->GetNumberOfScalarComponents() == 1)
186 retval.
mRawUid = QString(
"%1 [%2]").arg(QFileInfo(filename).completeBaseName()).arg(colorFormat);
195 QString colorFormat =
"R";
196 if (source->GetNumberOfScalarComponents() == 3)
198 vtkSmartPointer < vtkImageLuminance > luminance = vtkSmartPointer < vtkImageLuminance > ::New();
199 luminance->SetInputData(source);
205 else if (source->GetNumberOfScalarComponents() == 4)
208 colorFormat =
"RGBA";
210 else if (source->GetNumberOfScalarComponents() == 1)
216 retval.
mRawUid = QString(
"uchar %1[%2]").arg(QFileInfo(filename).completeBaseName()).arg(colorFormat);
231 image->setAcquisitionTime(QDateTime::currentDateTime());
232 package->mImage = image;
238 mUseSecondaryStream(false),
239 mPrimaryDataSource(),
240 mSecondaryDataSource()
250 vtkImageDataPtr DummyImageStreamer::internalLoadImage(QString filename)
255 std::cout <<
"DummyImageStreamer: Initialized with source file: " << getFileName().toStdString() << std::endl;
257 std::cout <<
"DummyImageStreamer: Failed to initialize with source file: " << getFileName().toStdString() << std::endl;
261 QString DummyImageStreamer::getFileName()
276 if (!this->shouldSetupSecondaryDataSource())
280 std::cout <<
"DummyImageStreamer: Initialized secondary data with uid=" << mSecondaryDataSource.
mRawUid << std::endl;
287 QString filename = arguments[
"filename"];
288 bool secondary = arguments.count(
"secondary") ?
true :
false;
294 mUseSecondaryStream = secondaryStream;
295 mFilename = filename;
302 this->createTestDataSource(source);
303 this->setSendOnce(sendonce);
312 reportError(
"DummyImageStreamer: Failed to start streaming: Not initialized.");
329 vtkSmartPointer<vtkImageData> DummyImageStreamer::hasSecondaryData()
334 void DummyImageStreamer::sendTestDataFrames()
339 if(!this->hasSecondaryData())
343 mSender->send(secondaryPackage);
346 void DummyImageStreamer::streamSlot()
351 this->sendTestDataFrames();
354 void DummyImageStreamer::setSendOnce(
bool sendonce)
356 mSendOnce = sendonce;
359 bool DummyImageStreamer::shouldSetupSecondaryDataSource()
361 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)
virtual void initialize(QString filename, bool secondaryStream, bool sendonce=false)
virtual QString getType()
vtkSmartPointer< class vtkImageMapToColors > vtkImageMapToColorsPtr
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)