16 #include "vtkImageData.h" 17 #include "vtkMetaImageReader.h" 18 #include "vtkLookupTable.h" 19 #include "vtkImageMapToColors.h" 24 #include <vtkImageExtractComponents.h> 25 #include <vtkImageAppendComponents.h> 26 #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)
234 std::cout <<
"DummyImageStreamer: Initialized with source file: " << getFileName().toStdString() << std::endl;
236 std::cout <<
"DummyImageStreamer: Failed to initialize with source file: " << getFileName().toStdString() << std::endl;
240 QString DummyImageStreamer::getFileName()
255 if (!this->shouldSetupSecondaryDataSource())
259 std::cout <<
"DummyImageStreamer: Initialized secondary data with uid=" << mSecondaryDataSource.
mRawUid << std::endl;
266 QString filename = arguments[
"filename"];
267 bool secondary = arguments.count(
"secondary") ?
true :
false;
273 mUseSecondaryStream = secondaryStream;
274 mFilename = filename;
281 this->createTestDataSource(source);
282 this->setSendOnce(sendonce);
291 reportError(
"DummyImageStreamer: Failed to start streaming: Not initialized.");
308 vtkSmartPointer<vtkImageData> DummyImageStreamer::hasSecondaryData()
313 void DummyImageStreamer::sendTestDataFrames()
318 if(!this->hasSecondaryData())
322 mSender->send(secondaryPackage);
325 void DummyImageStreamer::streamSlot()
330 this->sendTestDataFrames();
333 void DummyImageStreamer::setSendOnce(
bool sendonce)
335 mSendOnce = sendonce;
338 bool DummyImageStreamer::shouldSetupSecondaryDataSource()
340 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)
Namespace for all CustusX production code.