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;