| 31 | |
| 32 | |
| 33 | static |
| 34 | void SaveSliceOrImageAsPNG(std::vector<std::string> listOfOutputs, std::string path) |
| 35 | { |
| 36 | std::vector<mitk::ColorProperty::Pointer> colorList; |
| 37 | colorList.push_back(mitk::ColorProperty::New(0.9569, 0.16471, 0.25490)); // Red |
| 38 | colorList.push_back(mitk::ColorProperty::New(1, 0.839, 0)); // Yellow |
| 39 | colorList.push_back(mitk::ColorProperty::New(0, 0.6, 0.2)); // Green |
| 40 | colorList.push_back(mitk::ColorProperty::New(0, 0.2784, 0.7255)); // BLue |
| 41 | colorList.push_back(mitk::ColorProperty::New(1,0.3608,0)); // Orange |
| 42 | colorList.push_back(mitk::ColorProperty::New(0.839215,0.141176,0.80784)); // Violett |
| 43 | colorList.push_back(mitk::ColorProperty::New(0.1372,0.81568,0.7647)); // Turkis |
| 44 | colorList.push_back(mitk::ColorProperty::New(0.61176,0.9568,0.16078)); // Bright Green |
| 45 | colorList.push_back(mitk::ColorProperty::New(1,0.4274,0.16862)); // Dark Orange |
| 46 | colorList.push_back(mitk::ColorProperty::New(0.88633,0.14901,0.64705)); // Pink |
| 47 | |
| 48 | // Create a Standalone Datastorage for the single purpose of saving screenshots.. |
| 49 | mitk::StandaloneDataStorage::Pointer ds = mitk::StandaloneDataStorage::New(); |
| 50 | QmitkRenderWindow renderWindow; |
| 51 | renderWindow.GetRenderer()->SetDataStorage(ds); |
| 52 | |
| 53 | int numberOfSegmentations = 0; |
| 54 | bool isSegmentation = false; |
| 55 | for (auto name : listOfOutputs) |
| 56 | { |
| 57 | mitk::Image::Pointer tmpImage = mitk::IOUtil::Load<mitk::Image>(name); |
| 58 | auto nodeI = mitk::DataNode::New(); |
| 59 | nodeI->SetData(tmpImage); |
| 60 | nodeI->GetPropertyValue("binary",isSegmentation); |
| 61 | if (isSegmentation) |
| 62 | { |
| 63 | nodeI->SetProperty("color", colorList[numberOfSegmentations % colorList.size()]); |
| 64 | nodeI->SetProperty("binaryimage.hoveringannotationcolor", colorList[numberOfSegmentations % colorList.size()]); |
| 65 | nodeI->SetProperty("binaryimage.hoveringcolor", colorList[numberOfSegmentations % colorList.size()]); |
| 66 | nodeI->SetProperty("binaryimage.selectedannotationcolor", colorList[numberOfSegmentations % colorList.size()]); |
| 67 | nodeI->SetProperty("binaryimage.selectedcolor", colorList[numberOfSegmentations % colorList.size()]); |
| 68 | numberOfSegmentations++; |
| 69 | } |
| 70 | ds->Add(nodeI); |
| 71 | } |
| 72 | |
| 73 | auto geo = ds->ComputeBoundingGeometry3D(ds->GetAll()); |
| 74 | mitk::RenderingManager::GetInstance()->InitializeViews(geo); |
| 75 | |
| 76 | mitk::SliceNavigationController::Pointer sliceNaviController = renderWindow.GetSliceNavigationController(); |
| 77 | unsigned int numberOfSteps = 1; |
| 78 | if (sliceNaviController) |
| 79 | { |
| 80 | numberOfSteps = sliceNaviController->GetStepper()->GetSteps(); |
| 81 | sliceNaviController->GetStepper()->SetPos(0); |
| 82 | } |
| 83 | |
| 84 | renderWindow.show(); |
| 85 | renderWindow.resize(512, 512); |
| 86 | |
| 87 | for (unsigned int currentStep = 0; currentStep < numberOfSteps; ++currentStep) |
| 88 | { |
| 89 | if (sliceNaviController) |
| 90 | { |
no test coverage detected