18 #include "milxQtImage.h" 23 #include <vtkCamera.h> 24 #include <vtkImageMagnify.h> 25 #include <vtkRenderer.h> 26 #include <vtkRenderWindow.h> 27 #include <vtkImageActor.h> 28 #include <vtkImageMapToWindowLevelColors.h> 29 #include <vtkInteractorStyleImage.h> 30 #include <vtkPolyDataToImageStencil.h> 31 #include <vtkImageStencil.h> 32 #include <vtkImageFFT.h> 33 #include <vtkImageButterworthHighPass.h> 34 #include <vtkImageRFFT.h> 35 #include <vtkImageMagnitude.h> 36 #include <vtkImageGradientMagnitude.h> 37 #include <vtkImageShiftScale.h> 38 #include <vtkImageCast.h> 39 #include <vtkImageFlip.h> 40 #include <vtkImageReslice.h> 41 #include <vtkImageBlend.h> 42 #include <vtkDistanceRepresentation.h> 43 #include <vtkOrientedGlyphContourRepresentation.h> 44 #include <vtkBoxRepresentation.h> 45 #include <vtkImageActorPointPlacer.h> 46 #include <vtkDijkstraImageContourLineInterpolator.h> 47 #include <vtkDijkstraImageGeodesicPath.h> 48 #include <vtkTextProperty.h> 49 #include <vtkLogLookupTable.h> 51 #include "milxColourMap.h" 52 #include "milxQtFile.h" 90 imageData = vtkSmartPointer<vtkImageData>::New();
91 viewer = vtkSmartPointer<vtkImageViewer3>::New();
113 if(newImg->is8BitImage())
114 setData(newImg->GetCharImage(), newImg->isDisplayFlipped());
115 else if(newImg->is32BitImage())
116 setData(newImg->GetIntImage(), newImg->isDisplayFlipped());
117 else if(newImg->isVectorImage())
118 setData(newImg->GetVectorImage(), newImg->isDisplayFlipped(), forceDeepCopy);
119 else if(newImg->isRGBImage())
120 setData(newImg->GetRGBImage(), newImg->isDisplayFlipped());
122 setData(newImg->GetFloatImage(), newImg->isDisplayFlipped());
202 typedef double doublePixelType;
203 typedef itk::Image<doublePixelType, milx::imgDimension> doubleImageType;
207 printWarning(
"Matrix of Double type has been converted to Float type for display");
228 if( (newImg->GetNumberOfScalarComponents() == 4 || newImg->GetNumberOfScalarComponents() == 3) && newImg->GetScalarType() == VTK_UNSIGNED_CHAR )
241 if(newImg->is8BitImage())
242 setDisplayData(newImg->GetCharImage(), newImg->isDisplayFlipped());
243 else if(newImg->is32BitImage())
244 setDisplayData(newImg->GetIntImage(), newImg->isDisplayFlipped());
245 else if(newImg->isRGBImage())
246 setDisplayData(newImg->GetRGBImage(), newImg->isDisplayFlipped());
247 else if(newImg->isVectorImage())
248 setDisplayData(newImg->GetVectorImage(), newImg->isDisplayFlipped());
250 setDisplayData(newImg->GetFloatImage(), newImg->isDisplayFlipped());
319 if(slice >=
viewer->GetSliceMin() && slice <=
viewer->GetSliceMax())
331 vtkSmartPointer<vtkImageReslice> reslice = vtkSmartPointer<vtkImageReslice>::New();
332 #if VTK_MAJOR_VERSION <= 5 338 reslice->AutoCropOutputOn();
339 reslice->TransformInputSamplingOn();
340 reslice->SetOutputDimensionality(milx::imgDimension);
341 reslice->SetResliceTransform(newTransform);
346 #if VTK_MAJOR_VERSION <= 5 374 #if VTK_MAJOR_VERSION <= 5 384 printDebug(
"Size of Image window: " + QString::number(milxQtRenderWindow::GetRenderWindow()->GetSize()[0]) +
"x" + QString::number(milxQtRenderWindow::GetRenderWindow()->GetSize()[1]));
385 QVTKWidget::SetRenderWindow(
viewer->GetRenderWindow());
386 viewer->SetupInteractor(QVTKWidget::GetInteractor());
389 viewer->SetSlice(bounds[5]/2);
392 QVTKWidget::GetInteractor()->RemoveObservers(vtkCommand::RightButtonPressEvent);
393 QVTKWidget::GetInteractor()->RemoveObservers(vtkCommand::RightButtonReleaseEvent);
394 Connector->Connect(QVTKWidget::GetInteractor(),
395 vtkCommand::EndWindowLevelEvent,
397 SLOT( userEvent() ));
398 Connector->Connect(QVTKWidget::GetInteractor(),
399 vtkCommand::MouseWheelForwardEvent,
401 SLOT( userEvent() ));
402 Connector->Connect(QVTKWidget::GetInteractor(),
403 vtkCommand::MouseWheelBackwardEvent,
405 SLOT( userEvent() ));
406 Connector->Connect(QVTKWidget::GetInteractor(),
407 vtkCommand::KeyPressEvent,
409 SLOT( userEvent() ));
411 viewer->GetRenderer()->ResetCamera();
435 viewer->GetInteractorStyle()->InvokeEvent(vtkCommand::ResetWindowLevelEvent);
436 viewer->GetRenderer()->ResetCamera();
468 printInfo(
"Number of Image Components: " + QString::number(
imageData->GetNumberOfScalarComponents()));
469 if(
imageData->GetNumberOfScalarComponents() > 2)
491 double xSpacing = 1.0, ySpacing = 1.0, zSpacing = 1.0;
495 xSpacing = QInputDialog::getDouble(
this, tr(
"Please enter x spacing value"),
496 tr(
"X Spacing Value:"), 0.5, -2147483647, 2147483647, 7, &ok1);
497 ySpacing = QInputDialog::getDouble(
this, tr(
"Please enter y spacing value"),
498 tr(
"Y SpacingValue:"), 0.5, -2147483647, 2147483647, 7, &ok2);
499 zSpacing = QInputDialog::getDouble(
this, tr(
"Please enter z spacing value"),
500 tr(
"Z Spacing Value:"), 0.5, -2147483647, 2147483647, 7, &ok3);
503 if(ok1 && ok2 && ok3)
508 vtkSmartPointer<vtkImageData> whiteImage = vtkSmartPointer<vtkImageData>::New();
510 double totalBounds[6];
513 bounds = &totalBounds[0];
514 surfaceToVoxelise->GetBounds(bounds);
517 spacing[0] = xSpacing;
518 spacing[1] = ySpacing;
519 spacing[2] = zSpacing;
520 whiteImage->SetSpacing(spacing);
523 bounds[0] -= spacing[0];
524 bounds[1] += spacing[0];
525 bounds[2] -= spacing[1];
526 bounds[3] += spacing[1];
527 bounds[4] -= spacing[2];
528 bounds[5] += spacing[2];
532 for (
int i = 0; i < 3; i++)
534 dim[i] =
static_cast<int>( ceil((bounds[i * 2 + 1] - bounds[i * 2]) / spacing[i]) );
536 printInfo(
"Dimensions of Voxelisation is " + QString::number(dim[0]) +
"x" + QString::number(dim[1]) +
"x" + QString::number(dim[2]));
537 whiteImage->SetDimensions(dim);
538 whiteImage->SetExtent(0, dim[0] - 1, 0, dim[1] - 1, 0, dim[2] - 1);
542 origin[0] = bounds[0];
543 origin[1] = bounds[2];
544 origin[2] = bounds[4];
545 whiteImage->SetOrigin(origin);
546 #if VTK_MAJOR_VERSION <= 5 547 whiteImage->SetScalarTypeToUnsignedChar();
548 whiteImage->SetNumberOfScalarComponents(1);
549 whiteImage->AllocateScalars();
551 whiteImage->AllocateScalars(VTK_UNSIGNED_CHAR,1);
555 unsigned char inval = 255;
556 unsigned char outval = 0;
557 for (vtkIdType i = 0; i < whiteImage->GetNumberOfPoints(); ++i)
558 whiteImage->GetPointData()->GetScalars()->SetTuple1(i, inval);
561 printDebug(
"Polygonal data --> Image stencil");
562 vtkSmartPointer<vtkPolyDataToImageStencil> pol2stenc = vtkSmartPointer<vtkPolyDataToImageStencil>::New();
563 #if VTK_MAJOR_VERSION <= 5 564 pol2stenc->SetInput(surfaceToVoxelise);
566 pol2stenc->SetInputData(surfaceToVoxelise);
568 pol2stenc->SetOutputOrigin(origin);
569 pol2stenc->SetOutputSpacing(spacing);
570 pol2stenc->SetOutputWholeExtent(whiteImage->GetExtent());
576 vtkSmartPointer<vtkImageStencil> imgstenc = vtkSmartPointer<vtkImageStencil>::New();
577 #if VTK_MAJOR_VERSION <= 5 578 imgstenc->SetInput(whiteImage);
579 imgstenc->SetStencil(pol2stenc->GetOutput());
581 imgstenc->SetInputData(whiteImage);
582 imgstenc->SetStencilConnection(pol2stenc->GetOutputPort());
584 imgstenc->ReverseStencilOff();
585 imgstenc->SetBackgroundValue(outval);
599 vtkSmartPointer<vtkImageData> milxQtImage::butterWorthHighPass(vtkSmartPointer<vtkImageData> img)
601 printInfo(
"Computing the FFT of Image.");
602 vtkSmartPointer<vtkImageFFT> fft = vtkSmartPointer<vtkImageFFT>::New();
604 #if VTK_MAJOR_VERSION <= 5 607 fft->SetInputData(img);
612 printInfo(
"Filtering FFT space of Image.");
613 vtkSmartPointer<vtkImageButterworthHighPass> highPass = vtkSmartPointer<vtkImageButterworthHighPass>::New();
614 highPass->SetInputConnection(fft->GetOutputPort());
615 highPass->SetOrder(2);
616 highPass->SetXCutOff(0.2);
617 highPass->SetYCutOff(0.1);
619 highPass->ReleaseDataFlagOff();
621 printInfo(
"Computing the Inverse FFT of Image.");
622 vtkSmartPointer<vtkImageRFFT> ifft = vtkSmartPointer<vtkImageRFFT>::New();
623 ifft->SetInputConnection(highPass->GetOutputPort());
627 printInfo(
"Extracting the magnitude and casting to float image type.");
628 vtkSmartPointer<vtkImageMagnitude> magnitudeFilter = vtkSmartPointer<vtkImageMagnitude>::New();
629 magnitudeFilter->SetInputConnection(ifft->GetOutputPort());
632 vtkSmartPointer<vtkImageCast> rfftCastFilter = vtkSmartPointer<vtkImageCast>::New();
633 rfftCastFilter->SetInputConnection(magnitudeFilter->GetOutputPort());
634 rfftCastFilter->SetOutputScalarTypeToFloat();
636 rfftCastFilter->Update();
638 return rfftCastFilter->GetOutput();
648 vtkCommand::MiddleButtonPressEvent,
655 void milxQtImage::userEvent(QMouseEvent *event)
660 void milxQtImage::userEvent(QKeyEvent *event)
665 void milxQtImage::userEvent(QWheelEvent *event)
673 vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::SafeDownCast(obj);
678 QString message =
"";
681 vtkImageData* pImageData =
viewer->GetInput();
686 if( (pImageData->GetNumberOfScalarComponents() == 4 || pImageData->GetNumberOfScalarComponents() == 3)
687 && pImageData->GetScalarType() == VTK_UNSIGNED_CHAR )
689 message =
"RGB Image Pixel Cooridinates Diabled for Performance";
698 if (
dataPicker->Pick(iren->GetEventPosition()[0],
699 iren->GetEventPosition()[1],
713 coordinate current( ptMapped ), cell(0.0);
714 const int zAxis =
viewer->GetSliceOrientation();
715 int actual[3], relative[3];
716 double spacing[3], origin[3];
719 pImageData->GetSpacing(spacing);
720 pImageData->GetOrigin(origin);
723 if(zAxis == vtkImageViewer2::SLICE_ORIENTATION_XY)
725 current[2] = origin[2] +
viewer->GetSlice()*spacing[2];
728 else if(zAxis == vtkImageViewer2::SLICE_ORIENTATION_XZ)
731 current[1] = origin[1] +
viewer->GetSlice()*spacing[1];
734 else if(zAxis == vtkImageViewer2::SLICE_ORIENTATION_YZ)
738 current[0] = origin[0] +
viewer->GetSlice()*spacing[0];
743 int nVolIdx = pImageData->FindPoint(current.data_block());
744 const bool isInside = pImageData->ComputeStructuredCoordinates(current.data_block(), actual, cell.data_block());
746 relative[0] = actual[0];
747 relative[1] = actual[1];
748 relative[2] = actual[2];
759 switch (pImageData->GetNumberOfScalarComponents())
764 const double scalar = pImageData->GetScalarComponentAsDouble(actual[0], actual[1], actual[2], 0);
765 message =
"Point " + QString::number(nVolIdx) +
", Indices(" + QString::number(relative[0]) +
", " + QString::number(relative[1]) +
", " + QString::number(relative[2]) +
"), " 766 +
"Real(" + QString::number(current[0]) +
", " + QString::number(current[1]) +
", " + QString::number(current[2]) +
") = " 767 + QString::number(scalar);
774 const double scalarR = pImageData->GetScalarComponentAsDouble(actual[0], actual[1], actual[2], 0);
775 const double scalarG = pImageData->GetScalarComponentAsDouble(actual[0], actual[1], actual[2], 1);
776 message =
"Point " + QString::number(nVolIdx) +
", Indices(" + QString::number(relative[0]) +
", " + QString::number(relative[1]) +
", " + QString::number(relative[2]) +
"), " 777 +
"Real(" + QString::number(current[0]) +
", " + QString::number(current[1]) +
", " + QString::number(current[2]) +
") = " 778 +
"[" + QString::number(scalarR) +
"," + QString::number(scalarG) +
"]";
785 const double scalarR = pImageData->GetScalarComponentAsDouble(actual[0], actual[1], actual[2], 0);
786 const double scalarG = pImageData->GetScalarComponentAsDouble(actual[0], actual[1], actual[2], 1);
787 const double scalarB = pImageData->GetScalarComponentAsDouble(actual[0], actual[1], actual[2], 2);
788 message =
"Point " + QString::number(nVolIdx) +
", Indices(" + QString::number(relative[0]) +
", " + QString::number(relative[1]) +
", " + QString::number(relative[2]) +
"), " 789 +
"Real(" + QString::number(current[0]) +
", " + QString::number(current[1]) +
", " + QString::number(current[2]) +
") = " 790 +
"[" + QString::number(scalarR) +
"," + QString::number(scalarG) +
"," + QString::number(scalarB) +
"]";
795 message =
"Unsupported number of scalar components";
811 vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::SafeDownCast(obj);
813 string keyPressed = iren->GetKeySym();
816 if (keyPressed ==
"Up")
820 printDebug(
"Incrementing from Slice " + QString::number(
viewer->GetSlice()) +
" to Slice " + QString::number(
viewer->GetSlice()+1));
824 else if (keyPressed ==
"Down")
828 printDebug(
"Decrementing from Slice " + QString::number(
viewer->GetSlice()) +
" to Slice " + QString::number(
viewer->GetSlice()-1));
833 viewer->GetRenderWindow()->InvokeEvent(vtkCommand::ModifiedEvent, NULL);
839 vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::SafeDownCast(obj);
840 vtkRenderer* irenderer = iren->FindPokedRenderer(0,0);
844 vtkImageData* pImageData =
viewer->GetInput();
846 if (
dataPicker->Pick(iren->GetEventPosition()[0],
847 iren->GetEventPosition()[1],
854 coordinate current( ptMapped ), cell(0.0);
855 const int zAxis =
viewer->GetSliceOrientation();
861 const bool isInside = pImageData->ComputeStructuredCoordinates(current.data_block(), actual, cell.data_block());
865 if(zAxis == vtkImageViewer2::SLICE_ORIENTATION_XY)
867 viewer->SetSlice(actual[2]);
870 else if(zAxis == vtkImageViewer2::SLICE_ORIENTATION_XZ)
872 viewer->SetSlice(actual[1]);
875 else if(zAxis == vtkImageViewer2::SLICE_ORIENTATION_YZ)
877 viewer->SetSlice(actual[0]);
880 #if(VTK_MAJOR_VERSION > 5) 881 viewer->GetCursor()->SetCenter(current[0], current[1], current[2]);
883 viewer->GetCursor()->SetFocalPoint(current[0], current[1], current[2]);
885 viewer->GetCursor()->Update();
889 viewer->GetRenderWindow()->InvokeEvent(vtkCommand::ModifiedEvent, NULL);
905 printInfo(
"Contour Image Mode enabled.\nLeft Click to place points, Right click to place end point.");
906 printInfo(
"Delete key to delete point, Shift+Delete key to reset.");
908 vtkSmartPointer<vtkOrientedGlyphContourRepresentation> rep = vtkOrientedGlyphContourRepresentation::SafeDownCast(
milxQtRenderWindow::contourWidget->GetRepresentation() );
909 rep->GetLinesProperty()->SetColor(1, 0.2, 0);
910 rep->GetLinesProperty()->SetLineWidth(5.0);
913 vtkSmartPointer<vtkImageActorPointPlacer> pointPlacer = vtkSmartPointer<vtkImageActorPointPlacer>::New();
914 pointPlacer->SetImageActor(
viewer->GetImageActor());
915 rep->SetPointPlacer(pointPlacer);
919 vtkSmartPointer<vtkImageGradientMagnitude> grad = vtkSmartPointer<vtkImageGradientMagnitude>::New();
920 grad->SetDimensionality(3);
921 grad->HandleBoundariesOn();
922 #if VTK_MAJOR_VERSION <= 5 923 grad->SetInputConnection(
imageData->GetProducerPort());
931 double *range = grad->GetOutput()->GetScalarRange();
932 vtkSmartPointer<vtkImageShiftScale> gradInvert = vtkSmartPointer<vtkImageShiftScale>::New();
933 gradInvert->SetShift( -1.0*range[ 1 ] );
934 gradInvert->SetScale( 1.0 /( range[ 0 ] - range[ 1 ] ) );
935 gradInvert->SetOutputScalarTypeToFloat();
936 gradInvert->SetInputConnection( grad->GetOutputPort() );
937 gradInvert->Update();
940 vtkSmartPointer<vtkImageReslice> reslice = vtkSmartPointer<vtkImageReslice>::New();
941 reslice->SetOutputExtent(
viewer->GetImageActor()->GetDisplayExtent());
942 reslice->SetInputConnection(gradInvert->GetOutputPort());
943 reslice->SetOutputSpacing(
imageData->GetSpacing());
944 reslice->SetOutputOrigin(
imageData->GetOrigin());
948 vtkSmartPointer<vtkDijkstraImageContourLineInterpolator> interpolator = vtkSmartPointer<vtkDijkstraImageContourLineInterpolator>::New();
949 interpolator->SetCostImage(reslice->GetOutput());
950 vtkSmartPointer<vtkDijkstraImageGeodesicPath> path = interpolator->GetDijkstraImageGeodesicPath();
951 path->StopWhenEndReachedOn();
953 path->RepelPathFromVerticesOn();
956 path->SetCurvatureWeight( 0.15 );
957 path->SetEdgeLengthWeight( 0.8 );
958 path->SetImageWeight( 1.0 );
959 rep->SetLineInterpolator(interpolator);
982 floatImageType::DirectionType direction;
983 floatImageType::PointType origin;
984 floatImageType::SpacingType spacing;
985 vtkSmartPointer<vtkImageData> newImageData = vtkSmartPointer<vtkImageData>::New();
1028 printDebug(
"Updated Internal Char Image Data");
1034 direction =
imageInt->GetDirection();
1042 printDebug(
"Updated Internal Integer Image Data");
1048 direction =
imageRGB->GetDirection();
1056 printDebug(
"Updated Internal RGB Image Data");
1070 printDebug(
"Updated Internal Float Image Data");
1075 #if VTK_MAJOR_VERSION <= 5 1086 vtkCommand::KeyPressEvent,
1094 printInfo(
"Auto Updating Window Level");
1099 float belowValue = -1000, aboveValue = 4000, lowerPercentile = 1.0-percentile, upperPercentile = percentile;
1101 histogram(bins, belowValue, aboveValue,
false);
1107 size_t k = 0, kMin = 0, kMax = 0, kMid = 0;
1108 double binSpacing = (aboveValue-belowValue)/bins, accummulator = 0.0, proportion = 0.0;
1112 for(
double j = belowValue; j < aboveValue; j += binSpacing, k ++)
1114 proportion = accummulator/
hist->GetVoxelCount();
1115 if(proportion >= lowerPercentile)
1117 accummulator +=
hist->GetOutput()->GetPointData()->GetScalars()->GetTuple1(k);
1122 double lowLevel =
minValue+(kMin)*binSpacing;
1126 for(
double j = aboveValue; j > belowValue; j -= binSpacing, k --)
1128 proportion = accummulator/
hist->GetVoxelCount();
1129 if(proportion >= lowerPercentile)
1131 accummulator +=
hist->GetOutput()->GetPointData()->GetScalars()->GetTuple1(k);
1136 double maxLevel =
minValue+(kMax)*binSpacing;
1137 double windowLevel = maxLevel-lowLevel;
1138 double level = lowLevel+windowLevel/2;
1141 printDebug(
"Histogram Low Level:" + QString::number(lowLevel));
1142 printDebug(
"Histogram High Level:" + QString::number(maxLevel));
1143 printInfo(
"Window:" + QString::number(windowLevel));
1144 printInfo(
"Level:" + QString::number(level));
1146 viewer->SetColorWindow(windowLevel);
1147 viewer->SetColorLevel(level);
1157 double belowValue = range[0];
1158 double aboveValue = range[1];
1159 if(
imageData->GetNumberOfScalarComponents() > 2)
1165 float lvl = (aboveValue-belowValue)*level/100 + belowValue;
1166 printDebug(
"Contrast Level is "+QString::number(lvl));
1168 viewer->SetColorWindow(aboveValue-lvl);
1169 if(
imageData->GetNumberOfScalarComponents() > 2)
1170 viewer->SetColorWindow(255);
1171 viewer->SetColorLevel(lvl);
1178 return viewer->GetWindowLevel()->GetWindow();
1183 return viewer->GetWindowLevel()->GetLevel();
1188 viewer->GetWindowLevel()->SetWindow(window);
1193 viewer->GetWindowLevel()->SetLevel(level);
1196 #if (ITK_REVIEW || ITK_VERSION_MAJOR > 3) 1197 void milxQtImage::overlay(QString filename)
1201 if(filename.isEmpty())
1204 if(filename.isEmpty())
1207 QPointer<milxQtImage> labelledImage =
new milxQtImage;
1208 QPointer<milxQtFile> reader =
new milxQtFile;
1209 bool success = reader->
openImage(filename, labelledImage);
1220 if(labelledImage->is8BitImage())
1222 else if(labelledImage->is32BitImage())
1229 if(labelledImage->is8BitImage())
1231 else if(labelledImage->is32BitImage())
1240 if(labelledImage->is8BitImage())
1242 else if(labelledImage->is32BitImage())
1256 void milxQtImage::overlayContour(QString filename)
1258 printInfo(
"Overlaying Labelled Image as Contour");
1260 if(filename.isEmpty())
1265 if(filename.isEmpty())
1268 QPointer<milxQtImage> labelledImage =
new milxQtImage;
1269 QPointer<milxQtFile> reader =
new milxQtFile;
1270 bool success = reader->
openImage(filename, labelledImage);
1281 if(labelledImage->is8BitImage())
1283 else if(labelledImage->is32BitImage())
1290 if(labelledImage->is8BitImage())
1292 else if(labelledImage->is32BitImage())
1301 if(labelledImage->is8BitImage())
1303 else if(labelledImage->is32BitImage())
1317 void milxQtImage::computeContour()
1321 printError(
"Contour from VTK image not support yet.");
1325 printInfo(
"Computing Contour of Image");
1345 printError(
"Information from VTK image not support yet.");
1349 if(filename.isEmpty())
1352 if(filename.isEmpty())
1355 printInfo(
"Displaying Blending of the Images");
1358 QPointer<milxQtImage> imageToMatch =
new milxQtImage;
1359 QPointer<milxQtFile> reader =
new milxQtFile;
1360 bool success = reader->
openImage(filename, imageToMatch);
1368 imageToMatch->setName(filename);
1370 imageToMatch->generateImage();
1371 imageToMatch->setView(
getView());
1373 blend(imageToMatch, opacity);
1381 opacity = QInputDialog::getDouble(
this, tr(
"Please Provide the opacity of the blending"),
1382 tr(
"Opacity:"), 0.5, 0, 2147483647, 2, &ok1);
1389 printWarning(
"Lookuptable for one of the images was not set.");
1392 vtkSmartPointer<vtkImageData> ucharData1 =
GetWindowLevel()->GetOutput();
1395 vtkSmartPointer<vtkImageData> ucharData2 = imageToMatch->
GetWindowLevel()->GetOutput();
1396 printInfo(
"Number of components in Blending Image: " + QString::number(ucharData2->GetNumberOfScalarComponents()));
1399 vtkSmartPointer<vtkImageBlend>
blend = vtkSmartPointer<vtkImageBlend>::New();
1400 #if VTK_MAJOR_VERSION <= 5 1401 blend->AddInput(ucharData1);
1402 blend->AddInput(ucharData2);
1404 blend->AddInputData(ucharData1);
1405 blend->AddInputData(ucharData2);
1407 blend->SetOpacity(0,opacity);
1408 blend->SetOpacity(1,opacity);
1411 blend->SetBlendModeToNormal();
1414 printInfo(
"Number of components in Blended Image: " + QString::number(blend->GetOutput()->GetNumberOfScalarComponents()));
1415 printInfo(
"Type of pixel in Blended Image: " + QString(blend->GetOutput()->GetScalarTypeAsString()));
1425 viewer->GetRenderer()->ResetCamera();
1432 printInfo(
"Displaying Volume Rendering of Image");
1434 vtkSmartPointer<vtkImageData> img;
1437 vtkSmartPointer<vtkImageFlip> imageReorient = vtkSmartPointer<vtkImageFlip>::New();
1438 #if VTK_MAJOR_VERSION <= 5 1443 imageReorient->SetFilteredAxis(1);
1444 imageReorient->FlipAboutOriginOn();
1446 imageReorient->Update();
1447 img = imageReorient->GetOutput();
1459 printInfo(
"Computing Information of Image");
1463 floatImageType::DirectionType direction;
1464 floatImageType::PointType origin;
1465 floatImageType::SpacingType spacing;
1466 floatImageType::RegionType::SizeType imageSize;
1469 printWarning(
"Information from VTK image, as data not loaded as ITK image.");
1472 imageData->GetOrigin(origin.GetDataPointer());
1473 imageData->GetSpacing(spacing.GetDataPointer());
1476 imageSize[0] = extents[1]-extents[0];
1477 imageSize[1] = extents[3]-extents[2];
1478 imageSize[2] = extents[5]-extents[4];
1486 imageSize =
imageChar->GetLargestPossibleRegion().GetSize();
1488 printInfo(
"Image loaded as 8-bit image.");
1494 imageSize =
imageInt->GetLargestPossibleRegion().GetSize();
1495 direction =
imageInt->GetDirection();
1496 printInfo(
"Image loaded as Integer image.");
1502 imageSize =
imageRGB->GetLargestPossibleRegion().GetSize();
1503 direction =
imageRGB->GetDirection();
1504 printInfo(
"Image loaded as RGB image.");
1510 imageSize =
imageFloat->GetLargestPossibleRegion().GetSize();
1512 printInfo(
"Image loaded as floating-point image.");
1516 printInfo(
"Origin: (" + QString::number(origin[0]) +
", " + QString::number(origin[1]) +
", " + QString::number(origin[2]) +
")");
1517 printInfo(
"Spacing: (" + QString::number(spacing[0]) +
", " + QString::number(spacing[1]) +
", " + QString::number(spacing[2]) +
")");
1518 printInfo(
"Size: (" + QString::number(imageSize[0]) +
", " + QString::number(imageSize[1]) +
", " + QString::number(imageSize[2]) +
")");
1519 printInfo(
"Real Size: (" + QString::number(spacing[0]*imageSize[0]) +
", " + QString::number(spacing[1]*imageSize[1]) +
", " + QString::number(spacing[2]*imageSize[2]) +
")");
1523 printInfo(
"|" + QString::number(direction(0,0)) +
", " + QString::number(direction(0,1)) +
", " + QString::number(direction(0,2)) +
"|");
1524 printInfo(
"|" + QString::number(direction(1,0)) +
", " + QString::number(direction(1,1)) +
", " + QString::number(direction(1,2)) +
"|");
1525 printInfo(
"|" + QString::number(direction(2,0)) +
", " + QString::number(direction(2,1)) +
", " + QString::number(direction(2,2)) +
"|");
1527 QString orientFlagStr;
1536 printInfo(
"Orientation Flag: " + orientFlagStr);
1546 printError(
"Rescale from VTK image not support yet.");
1551 float newMinValue = QInputDialog::getDouble(
this, tr(
"Please Provide the minimum value of new intensities"),
1552 tr(
"Minimum:"),
minValue, -2147483647, 2147483647, 1, &ok1);
1553 float newMaxValue = QInputDialog::getDouble(
this, tr(
"Please Provide the maximum value of new intensities"),
1554 tr(
"Maximum:"),
maxValue, -2147483647, 2147483647, 1, &ok2);
1559 printInfo(
"Rescaling Intensities of Image");
1578 printError(
"Relabelling from VTK image not support yet.");
1588 printError(
"Relabelling only supports labelled images.");
1600 printError(
"Histogram equalisation from VTK image not support yet.");
1613 printInfo(
"Histogram Equalisation of Image");
1632 printError(
"Gradient Magnitude from VTK image not support yet.");
1636 printInfo(
"Computing Gradient Magnitude of Image");
1655 printError(
"Sobel Edges from VTK image not support yet.");
1659 printInfo(
"Computing Sobel Edges of Image");
1684 printError(
"Canny Edges from VTK image not support yet.");
1689 float variance = QInputDialog::getDouble(
this, tr(
"Please Provide the variance"),
1690 tr(
"Variance:"), 2.0, 0.0, 1000.0, 5, &ok1);
1691 float upper = QInputDialog::getDouble(
this, tr(
"Please Provide the upper threshold"),
1693 float lower = QInputDialog::getDouble(
this, tr(
"Please Provide the lower threshold"),
1696 if(!ok1 || !ok2 || !ok3)
1699 printInfo(
"Computing Canny Edges of Image");
1726 printError(
"Laplacian from VTK image not support yet.");
1730 printInfo(
"Computing Laplacian of Image");
1757 printError(
"Normalizing from VTK image not support yet.");
1789 printError(
"Invert Intensity from VTK image not support yet.");
1795 printInfo(
"Inverting Intensity of Image");
1831 printError(
"Matching Info from VTK image not support yet.");
1835 if(filename.isEmpty())
1838 if(filename.isEmpty())
1841 QPointer<milxQtImage> imageToMatch =
new milxQtImage;
1842 QPointer<milxQtFile> reader =
new milxQtFile;
1843 bool success = reader->
openImage(filename, imageToMatch);
1853 printInfo(
"Matching Histogram of Image");
1872 printError(
"Matching Histogram from VTK image not support yet.");
1876 if(filename.isEmpty())
1879 if(filename.isEmpty())
1882 QPointer<milxQtImage> imageToMatch =
new milxQtImage;
1883 QPointer<milxQtFile> reader =
new milxQtFile;
1884 bool success = reader->
openImage(filename, imageToMatch);
1896 printError(
"Resampling from VTK image not support yet.");
1900 if(filename.isEmpty())
1903 if(filename.isEmpty())
1906 QPointer<milxQtImage> imageToMatch =
new milxQtImage;
1907 QPointer<milxQtFile> reader =
new milxQtFile;
1908 bool success = reader->
openImage(filename, imageToMatch);
1917 if(imageToMatch->is8BitImage())
1919 else if(imageToMatch->is32BitImage())
1933 if(imageToMatch->is8BitImage())
1939 else if(imageToMatch->is32BitImage())
1951 if(imageToMatch->is8BitImage())
1968 printError(
"Masking from VTK image not support yet.");
1972 if(filename.isEmpty())
1975 if(filename.isEmpty())
1978 QPointer<milxQtImage> imageToMatch =
new milxQtImage;
1979 QPointer<milxQtFile> reader =
new milxQtFile;
1980 bool success = reader->
openImage(filename, imageToMatch);
1989 if(imageToMatch->is8BitImage())
1996 if(imageToMatch->is8BitImage())
2003 #if ITK_VERSION_MAJOR > 3 2006 if(imageToMatch->is8BitImage())
2016 if(imageToMatch->is8BitImage())
2030 printError(
"Resampling from VTK image not support yet.");
2034 bool ok1 =
false, ok2 =
false, ok3 =
false;
2035 if(xSampleFactor == 0 && ySampleFactor == 0 && zSampleFactor == 0)
2037 xSampleFactor = QInputDialog::getInt(
this, tr(
"Please Provide the downsample factors"),
2038 tr(
"X Factor:"), 2, 0, 1000, 1, &ok1);
2039 ySampleFactor = QInputDialog::getInt(
this, tr(
"Please Provide the downsample factors"),
2040 tr(
"Y Factor:"), 2, 0, 1000, 1, &ok2);
2041 zSampleFactor = QInputDialog::getInt(
this, tr(
"Please Provide the downsample factors"),
2042 tr(
"Z Factor:"), 2, 0, 1000, 1, &ok3);
2045 if(!ok1 || !ok2 || !ok3)
2050 floatImageType::SizeType factors;
2051 factors[0] = xSampleFactor;
2052 factors[1] = ySampleFactor;
2053 factors[2] = zSampleFactor;
2073 printError(
"Masking from VTK image not support yet.");
2077 if(filename.isEmpty())
2080 if(filename.isEmpty())
2083 QPointer<milxQtImage> imageToMatch =
new milxQtImage;
2084 QPointer<milxQtFile> reader =
new milxQtFile;
2085 bool success = reader->
openImage(filename, imageToMatch);
2090 #if (ITK_REVIEW || ITK_VERSION_MAJOR > 3) 2091 printInfo(
"Masking and Cropping Image");
2095 if(imageToMatch->is8BitImage())
2102 if(imageToMatch->is8BitImage())
2111 if(imageToMatch->is8BitImage())
2120 if(imageToMatch->is8BitImage())
2126 #endif // (ITK_REVIEW || ITK_VERSION_MAJOR > 3) 2135 printError(
"Resampling from VTK image not support yet.");
2139 if(filename.isEmpty())
2142 if(filename.isEmpty())
2145 QPointer<milxQtImage> imageToMatch =
new milxQtImage;
2146 QPointer<milxQtFile> reader =
new milxQtFile;
2147 bool success = reader->
openImage(filename, imageToMatch);
2152 printInfo(
"Resampling as Labelled Image");
2156 if(imageToMatch->is8BitImage())
2166 if(imageToMatch->is8BitImage())
2182 if(imageToMatch->is8BitImage())
2199 printError(
"Checker Board from VTK image not support yet.");
2203 if(filename.isEmpty())
2205 filename =
getOpenFilename(
"Select Transform File",
"ITK Transform Files (*.txt *.tfm);;VTK Transform Files (*.trsf)");
2208 msgBox.setText(
"Use Reference Image");
2209 msgBox.setInformativeText(
"Do you want to resample to a reference image?");
2210 msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
2211 msgBox.setDefaultButton(QMessageBox::Yes);
2212 int ret1 = msgBox.exec();
2214 if(ret1 == QMessageBox::Yes)
2217 QMessageBox msgBox2;
2218 msgBox2.setText(
"Invert Transform");
2219 msgBox2.setInformativeText(
"Do you want to invert the transform?");
2220 msgBox2.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
2221 msgBox2.setDefaultButton(QMessageBox::Yes);
2222 int ret2 = msgBox2.exec();
2224 if(ret2 == QMessageBox::Yes)
2228 if(filename.isEmpty())
2231 typedef double transformType;
2232 typedef itk::Transform<transformType> TransformType;
2233 TransformType::Pointer transf = milx::File::OpenTransform<transformType>(filename.toStdString());
2235 cout <<
"Transform to be used: ";
2238 QPointer<milxQtImage> imageToMatch =
new milxQtImage;
2239 QPointer<milxQtFile> reader =
new milxQtFile;
2240 bool success =
false;
2241 if(!refImgFilename.isEmpty())
2243 success = reader->
openImage(refImgFilename, imageToMatch);
2249 printInfo(
"Transforming Image with " + QString(transf->GetTransformTypeAsString().c_str()));
2251 if(!refImgFilename.isEmpty())
2255 if(imageToMatch->is8BitImage())
2265 if(imageToMatch->is8BitImage())
2281 if(imageToMatch->is8BitImage())
2292 printDebug(
"Transforming without reference image");
2295 if(imageToMatch->is8BitImage())
2305 if(imageToMatch->is8BitImage())
2321 if(imageToMatch->is8BitImage())
2340 printError(
"Checker Board from VTK image not support yet.");
2345 if(numberOfSquares == 0)
2347 numberOfSquares = QInputDialog::getInt(
this, tr(
"Please Provide the number of squares"),
2348 tr(
"Squares:"), 10, 0, 100, 1, &ok);
2370 viewer->GetImageActor()->GetDisplayExtent(extent);
2374 int actualExtent[6];
2377 if(extent[3]-extent[2] == 0)
2379 extent[2] = actualExtent[3]-extent[2];
2380 extent[3] = actualExtent[3]-extent[3];
2386 typedef itk::Image<charPixelType, 2> charImage2DType;
2394 typedef itk::Image<intPixelType, 2> intImage2DType;
2404 typedef itk::Image<floatPixelType, 2> floatImage2DType;
2424 printError(
"Checker Board from VTK image not support yet.");
2428 if(filename.isEmpty())
2431 if(filename.isEmpty())
2434 QPointer<milxQtImage> imageToMatch =
new milxQtImage;
2435 QPointer<milxQtFile> reader =
new milxQtFile;
2436 bool success = reader->
openImage(filename, imageToMatch);
2448 printError(
"Distance Map from VTK image not support yet.");
2499 printError(
"Threshold above for VTK image not support yet.");
2505 bool ok1 =
false, ok2 =
false;
2506 if(value == 0 && level == 0)
2508 value = QInputDialog::getDouble(
this, tr(
"Please Provide Outside Value"),
2510 level = QInputDialog::getDouble(
this, tr(
"Please Provide the threshold upper level"),
2517 printInfo(
"Thresholding Image from above");
2536 printError(
"Threshold below for VTK image not support yet.");
2542 bool ok1 =
false, ok2 =
false;
2543 if(value == 0 && level == 0)
2545 value = QInputDialog::getDouble(
this, tr(
"Please Provide Outside Value"),
2547 level = QInputDialog::getDouble(
this, tr(
"Please Provide the threshold lower level"),
2554 printInfo(
"Thresholding Image from below");
2573 printError(
"Threshold for VTK image not support yet.");
2579 bool ok1 =
false, ok2 =
false, ok3 =
false;
2580 if(value == 0 && blevel == 0 && alevel == 0)
2582 value = QInputDialog::getDouble(
this, tr(
"Please Provide Outside Value"),
2584 blevel = QInputDialog::getDouble(
this, tr(
"Please Provide the threshold lower level"),
2586 alevel = QInputDialog::getDouble(
this, tr(
"Please Provide the threshold upper level"),
2589 if(!ok1 || !ok2 || !ok3)
2612 printError(
"Otsu Threshold for VTK image not support yet.");
2621 bins = QInputDialog::getInt(
this, tr(
"Please Provide the histogram bins to use"),
2622 tr(
"Bins:"), 128, 0, 8192, 1, &ok);
2649 printError(
"Otsu Multiple Threshold for VTK image not support yet.");
2658 bins = QInputDialog::getInt(
this, tr(
"Please Provide the histogram bins to use"),
2659 tr(
"Bins:"), 128, 0, 8192, 1, &ok);
2660 labels = QInputDialog::getInt(
this, tr(
"Please Provide the number of labels to produce"),
2661 tr(
"Labels:"), 1, 0, 8192, 1, &ok);
2667 printInfo(
"Otsu Multiple Thresholding Image");
2688 printError(
"Binary Threshold for VTK image not support yet.");
2694 bool ok1 =
false, ok2 =
false, ok3 =
false;
2695 if(value == 0 && blevel == 0 && alevel == 0)
2697 value = QInputDialog::getDouble(
this, tr(
"Please Provide Inside Value"),
2698 tr(
"Inside Value:"), 1.0, 0, 255, 1, &ok1);
2699 blevel = QInputDialog::getDouble(
this, tr(
"Please Provide the threshold lower level"),
2701 alevel = QInputDialog::getDouble(
this, tr(
"Please Provide the threshold upper level"),
2704 if(!ok1 || !ok2 || !ok3)
2729 printError(
"Flipping from VTK image not support yet.");
2733 if(!xAxis && !yAxis && !zAxis)
2735 QMessageBox msgBoxX, msgBoxY, msgBoxZ, msgBoxOrigin;
2736 msgBoxX.setText(
"The image will be flipped");
2737 msgBoxX.setInformativeText(
"Do you want to flip the x-axis?");
2738 msgBoxX.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
2739 msgBoxX.setDefaultButton(QMessageBox::No);
2740 msgBoxY.setText(
"The image will be flipped");
2741 msgBoxY.setInformativeText(
"Do you want to flip the y-axis?");
2742 msgBoxY.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
2743 msgBoxY.setDefaultButton(QMessageBox::Yes);
2744 msgBoxZ.setText(
"The image will be flipped");
2745 msgBoxZ.setInformativeText(
"Do you want to flip the z-axis?");
2746 msgBoxZ.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
2747 msgBoxZ.setDefaultButton(QMessageBox::No);
2748 msgBoxOrigin.setText(
"The image will be flipped");
2749 msgBoxOrigin.setInformativeText(
"Do you want to flip about the origin?");
2750 msgBoxOrigin.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
2751 msgBoxOrigin.setDefaultButton(QMessageBox::Yes);
2752 int retX = msgBoxX.exec();
2753 int retY = msgBoxY.exec();
2754 int retZ = msgBoxZ.exec();
2755 int retOrigin = msgBoxOrigin.exec();
2757 if(retX == QMessageBox::Yes)
2759 if(retY == QMessageBox::Yes)
2761 if(retZ == QMessageBox::Yes)
2763 if(retOrigin == QMessageBox::Yes)
2766 aboutOrigin =
false;
2810 viewer->GetRenderer()->ResetCamera();
2835 printInfo(
"Loaded image as vector image.");
2836 printDebug(
"Computing magnitude of field image.");
2852 index = QInputDialog::getInt(
this, tr(
"Please Provide the component index to display"),
2853 tr(
"Component:"), 0, 0,
imageVector->GetNumberOfComponentsPerPixel(), 1, &ok1);
2881 const size_t components =
imageVector->GetNumberOfComponentsPerPixel();
2882 int ret = QMessageBox::No;
2886 msgBox.setText(
"Tensor Field?");
2887 msgBox.setInformativeText(
"Found more than 3 components. Do you wish to compute a tensor field?");
2888 msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
2889 msgBox.setDefaultButton(QMessageBox::Yes);
2890 ret = msgBox.exec();
2894 if(ret == QMessageBox::Yes)
2907 const size_t components =
imageVector->GetNumberOfComponentsPerPixel();
2910 printError(
"Can only integrate vector fields. Number of Components must be 3.");
2915 viewer->GetImageActor()->GetDisplayExtent(extent);
2919 int actualExtent[6];
2922 if(extent[3]-extent[2] == 0)
2924 extent[2] = actualExtent[3]-extent[2];
2925 extent[3] = actualExtent[3]-extent[3];
2939 printError(
"Anisotropic Diffusion from VTK image not support yet.");
2944 floatImageType::SizeType imgSize;
2946 imgSize =
imageChar->GetLargestPossibleRegion().GetSize();
2948 imgSize =
imageFloat->GetLargestPossibleRegion().GetSize();
2950 size_t maxDimension = 0;
2951 for(
size_t k = 0; k < imgSize.GetSizeDimension(); k ++)
2953 if(imgSize[k] > maxDimension)
2954 maxDimension = imgSize[k];
2956 printDebug(
"Timestep will be initially the reciprocal of " + QString::number(maxDimension));
2957 float timestep = 2.0/maxDimension;
2959 bool ok1 =
false, ok2 =
false;
2960 int iterations = QInputDialog::getInt(
this, tr(
"Please Provide the number of Iterations"),
2961 tr(
"Iterations:"), 5, 0, 1000, 1, &ok1);
2962 timestep = QInputDialog::getDouble(
this, tr(
"Please Provide the timestep"),
2963 tr(
"Timestep:"), timestep, 0.0, 100.0, 5, &ok2);
2967 printInfo(
"Computing Anisotropic Diffusion of Image");
2993 printError(
"Gaussian Smoothin from VTK image not support yet.");
2998 float variance = QInputDialog::getDouble(
this, tr(
"Please Provide the variance of the Gaussian to use"),
2999 tr(
"Variance:"), 0.5, 0.0, 2147483647, 5, &ok1);
3003 printInfo(
"Computing Gaussian Smoothing of Image");
3023 printError(
"Bilateral Smoothin from VTK image not support yet.");
3027 bool ok1 =
false, ok2 =
false;
3028 float sigmaRange = QInputDialog::getDouble(
this, tr(
"Please Provide the range sigma to use"),
3029 tr(
"Range Sigma:"), 0.5, 0.0, 2147483647, 5, &ok1);
3030 float sigmaSpatial = QInputDialog::getDouble(
this, tr(
"Please Provide the domain/spatial sigma to use"),
3031 tr(
"Domain Sigma:"), 5, 0.0, 2147483647, 5, &ok2);
3035 printInfo(
"Computing Bilateral Smoothing of Image");
3055 printError(
"Median from VTK image not support yet.");
3060 int radius = QInputDialog::getInt(
this, tr(
"Please Provide the radius to use"),
3061 tr(
"Radius:"), 5, 0, 1000, 1, &ok);
3085 printError(
"Adding of VTK image not support yet.");
3093 charImageType::SizeType blankSize;
3094 blankSize[0] = xSize;
3095 blankSize[1] = ySize;
3096 blankSize[2] = zSize;
3109 intImageType::SizeType blankSize;
3110 blankSize[0] = xSize;
3111 blankSize[1] = ySize;
3112 blankSize[2] = zSize;
3125 rgbImageType::SizeType blankSize;
3126 blankSize[0] = xSize;
3127 blankSize[1] = ySize;
3128 blankSize[2] = zSize;
3141 floatImageType::SizeType blankSize;
3142 blankSize[0] = xSize;
3143 blankSize[1] = ySize;
3144 blankSize[2] = zSize;
3156 printError(
"Blank image of different types not supported.");
3164 floatImageType::SpacingType newSpacing;
3165 floatImageType::SizeType newSize;
3166 floatImageType::PointType newOrigin;
3167 floatImageType::DirectionType newDirection;
3171 newSize =
imageChar->GetLargestPossibleRegion().GetSize();
3173 newDirection =
imageChar->GetDirection();
3177 newSpacing =
imageInt->GetSpacing();
3178 newSize =
imageInt->GetLargestPossibleRegion().GetSize();
3180 newDirection =
imageInt->GetDirection();
3185 newSize =
imageFloat->GetLargestPossibleRegion().GetSize();
3191 printError(
"Resize image of different types not supported.");
3196 if(outputSpacing == 0.0)
3198 outputSpacing = QInputDialog::getDouble(
this, tr(
"Please Provide the new isotropic spacing"),
3199 tr(
"Isotropic Spacing:"), 0.5, 0.001, 10, 3, &ok1);
3205 printInfo(
"Resizing Image based on new spacing");
3207 floatImageType::SpacingType scaleFactor;
3208 scaleFactor[0] = newSpacing[0]/outputSpacing;
3209 scaleFactor[1] = newSpacing[1]/outputSpacing;
3210 scaleFactor[2] = newSpacing[2]/outputSpacing;
3211 newSpacing.Fill(outputSpacing);
3212 newSize[0] =
static_cast<unsigned>(newSize[0]*scaleFactor[0]+0.5);
3213 newSize[1] =
static_cast<unsigned>(newSize[1]*scaleFactor[1]+0.5);
3214 newSize[2] =
static_cast<unsigned>(newSize[2]*scaleFactor[2]+0.5);
3215 std::cout <<
"Rescaling image by [" << scaleFactor[0] <<
", " << scaleFactor[1] <<
", " << scaleFactor[2] <<
"]" << std::endl;
3216 std::cout <<
"Resampling image to [" << newSize[0] <<
", " << newSize[1] <<
", " << newSize[2] <<
"]" << std::endl;
3233 printError(
"Adding of VTK image not support yet.");
3241 charImageType::SizeType blankSize;
3242 blankSize[0] = xSize;
3243 blankSize[1] = ySize;
3244 blankSize[2] = zSize;
3253 intImageType::SizeType blankSize;
3254 blankSize[0] = xSize;
3255 blankSize[1] = ySize;
3256 blankSize[2] = zSize;
3277 floatImageType::SizeType blankSize;
3278 blankSize[0] = xSize;
3279 blankSize[1] = ySize;
3280 blankSize[2] = zSize;
3288 printError(
"Blank image of different types not supported.");
3298 printError(
"Adding of VTK image not support yet.");
3318 printError(
"Adding images of different types not supported.");
3328 printError(
"Adding from VTK image not support yet.");
3332 if(filename.isEmpty())
3335 if(filename.isEmpty())
3338 QPointer<milxQtImage> imageToSubtract =
new milxQtImage;
3339 QPointer<milxQtFile> reader =
new milxQtFile;
3340 bool success = reader->
openImage(filename, imageToSubtract);
3345 add(imageToSubtract);
3352 printError(
"Subtracting of VTK image not support yet.");
3372 printError(
"Subtracting images of different types not supported.");
3382 printError(
"Subtracting from VTK image not support yet.");
3386 if(filename.isEmpty())
3389 if(filename.isEmpty())
3392 QPointer<milxQtImage> imageToSubtract =
new milxQtImage;
3393 QPointer<milxQtFile> reader =
new milxQtFile;
3394 bool success = reader->
openImage(filename, imageToSubtract);
3406 printError(
"Multiplying of VTK image not support yet.");
3419 printError(
"Multiplying images of Vector, RGB or different types not supported.");
3429 printError(
"Multiplying from VTK image not support yet.");
3433 if (filename.isEmpty())
3436 if (filename.isEmpty())
3439 QPointer<milxQtImage> imageToMultiply =
new milxQtImage;
3440 QPointer<milxQtFile> reader =
new milxQtFile;
3441 bool success = reader->
openImage(filename, imageToMultiply);
3453 printError(
"Scaling of VTK image not support yet.");
3487 printError(
"Convolving of VTK images not support yet.");
3490 #if (ITK_REVIEW || ITK_VERSION_MAJOR > 3) //Review only members 3507 printError(
"Convolving images of different types not supported.");
3518 typedef itk::VTKImageToImageFilter<floatImageType> ConvertImageType;
3520 ConvertImageType::Pointer convertFilter = ConvertImageType::New();
3525 convertFilter->Update();
3527 catch (itk::ExceptionObject & ex )
3529 printError(
"Failed Converting VTK Image to ITK Image");
3543 if(
viewer->GetImageActor()->GetInterpolate())
3546 viewer->GetImageActor()->InterpolateOff();
3552 viewer->GetImageActor()->InterpolateOn();
3567 viewer->GetRenderer()->ResetCamera();
3577 if(orientMode == RADIOLOGICAL)
3578 viewer->NeurologicalViewOff();
3579 if(orientMode == NEUROLOGICAL)
3580 viewer->NeurologicalViewOn();
3594 msgBox.setText(
"An auto adjusted bar is about to be created");
3595 msgBox.setInformativeText(
"Would you like to customise the bar?");
3596 msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
3597 msgBox.setDefaultButton(QMessageBox::No);
3599 int ret = QMessageBox::No;
3601 ret = msgBox.exec();
3603 const float barWidth = 0.1, barHeight = 0.7;
3610 vtkSmartPointer<vtkLogLookupTable> logLookupTable;
3614 logLookupTable = vtkSmartPointer<vtkLogLookupTable>::New();
3615 logLookupTable->DeepCopy(vtkLookupTable::SafeDownCast(
lookupTable));
3618 if(ret == QMessageBox::Yes && !quiet)
3620 bool ok1 =
false, ok2 =
false;
3622 noOfLabels = QInputDialog::getInt(
this, tr(
"How many labels to show"),
3623 tr(
"Labels:"), noOfLabels, 0, 99, 1, &ok1);
3624 title = QInputDialog::getText(
this, tr(
"Title of Bar"),
3625 tr(
"Title:"), QLineEdit::Normal,
3637 vtkImageMapToWindowLevelColors *filterColorsOverlay =
viewer->GetWindowLevel();
3639 filterColorsOverlay->PassAlphaToOutputOn();
3640 filterColorsOverlay->Update();
3642 milxQtRenderWindow::customScalarBar =
true;
3644 else if(quiet && minRange != maxRange)
3646 printInfo(
"Using custom scalar range for scalars.");
3653 vtkImageMapToWindowLevelColors *filterColorsOverlay =
viewer->GetWindowLevel();
3655 filterColorsOverlay->PassAlphaToOutputOn();
3656 filterColorsOverlay->Update();
3658 milxQtRenderWindow::customScalarBar =
true;
3662 printInfo(
"Using scalar range from image.");
3669 vtkImageMapToWindowLevelColors *filterColorsOverlay =
viewer->GetWindowLevel();
3671 filterColorsOverlay->PassAlphaToOutputOn();
3672 filterColorsOverlay->Update();
3674 milxQtRenderWindow::customScalarBar =
false;
3709 printError(
"Image Data not generated. Ignoring scalar bar operation.");
3716 msgBox.setText(
"Currently not using a colour map");
3717 msgBox.setInformativeText(
"Please choose a colour map first");
3718 msgBox.setStandardButtons(QMessageBox::Ok);
3719 msgBox.setIcon(QMessageBox::Warning);
3725 if(
scaleAct->isChecked() || forceDisplay)
3733 #if VTK_MAJOR_VERSION > 5 3734 void milxQtImage::resliceMode(
const bool quietly)
3737 enableResliceMode();
3739 disableResliceMode();
3761 printDebug(
"Volume is 2D. Not changing view to " + QString::number(viewMode));
3773 viewer->SetSliceOrientationToXY();
3782 viewer->SetSliceOrientationToXZ();
3791 viewer->SetSliceOrientationToYZ();
3803 vtkImageMapToWindowLevelColors *filterColorsOverlay =
viewer->GetWindowLevel();
3805 filterColorsOverlay->PassAlphaToOutputOn();
3806 filterColorsOverlay->Update();
3813 printInfo(
"Computing Histogram of Image");
3819 int ret = QMessageBox::No;
3823 bool ok1 =
false, ok2 =
false, ok3 =
false;
3824 bins = QInputDialog::getInt(
this, tr(
"Please Provide the number of bins"),
3825 tr(
"Number of Bins:"), 256, 2, 16384, 1, &ok1);
3826 belowValue = QInputDialog::getDouble(
this, tr(
"Please Provide the lower level"),
3827 tr(
"Lower Level:"), range[0], -2147483647, 2147483647, 1, &ok2);
3828 aboveValue = QInputDialog::getDouble(
this, tr(
"Please Provide the upper level"),
3829 tr(
"Upper Level:"), range[1], belowValue, 2147483647, 1, &ok3);
3831 if(!ok1 || !ok2 || !ok3)
3835 msgBox.setText(
"Ignore Zero Values in Statistics?");
3836 msgBox.setInformativeText(
"Do you wish to ignore zero values in Max/Min/Sum/Mean statistics?");
3837 msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
3838 msgBox.setDefaultButton(QMessageBox::No);
3839 ret = msgBox.exec();
3843 belowValue = range[0];
3844 aboveValue = range[1];
3847 double binSpacing = (aboveValue-belowValue)/bins;
3848 printInfo(
"Bin Spacing: " + QString::number(binSpacing));
3849 hist = vtkSmartPointer<vtkImageAccumulate>::New();
3850 #if VTK_MAJOR_VERSION <= 5 3856 hist->SetComponentExtent(0, bins-1, 0, 0, 0, 0);
3857 hist->SetComponentOrigin(belowValue, 0, 0);
3858 hist->SetComponentSpacing(binSpacing, 0, 0);
3859 if(ret == QMessageBox::Yes)
3861 printWarning(
"Ignore zero values in summary statistics");
3862 hist->IgnoreZeroOn();
3865 hist->IgnoreZeroOff();
3870 const coordinate meanTuple(
hist->GetMean() );
3871 const coordinate stddevTuple(
hist->GetStandardDeviation());
3872 const coordinate minTuple(
hist->GetMin() );
3873 const coordinate maxTuple(
hist->GetMax() );
3874 if(
imageData->GetNumberOfScalarComponents() == 1)
3894 #if VTK_MAJOR_VERSION <= 5 3895 hist->GetOutput()->Update();
3898 vtkSmartPointer<vtkFloatArray> binsArray = vtkSmartPointer<vtkFloatArray>::New();
3899 binsArray->SetNumberOfComponents(1);
3900 binsArray->SetNumberOfTuples(bins);
3901 binsArray->SetName(
"Greyscale Bins");
3902 vtkSmartPointer<vtkIntArray> freqArray = vtkSmartPointer<vtkIntArray>::New();
3903 freqArray->SetNumberOfComponents(1);
3904 freqArray->SetNumberOfTuples(bins);
3905 freqArray->SetName(
"Frequency");
3906 freqArray->FillComponent(0, 0);
3908 for(
float j = belowValue; j < aboveValue; j += binSpacing, k ++)
3910 binsArray->SetTuple1(k, j);
3911 freqArray->SetTuple1(k,
hist->GetOutput()->GetPointData()->GetScalars()->GetTuple1(k));
3914 vtkSmartPointer<vtkTable> table = vtkSmartPointer<vtkTable>::New();
3915 table->AddColumn(binsArray);
3916 table->AddColumn(freqArray);
3925 viewer->GetImageActor()->GetDisplayExtent(extent);
3927 QString::number(extent[0]) +
", " + QString::number(extent[1]) +
", " +
3928 QString::number(extent[2]) +
", " + QString::number(extent[3]) +
", " +
3929 QString::number(extent[4]) +
", " + QString::number(extent[5]) +
"]");
3931 vtkSmartPointer<vtkImageData> img;
3934 vtkSmartPointer<vtkImageFlip> imageReorient = vtkSmartPointer<vtkImageFlip>::New();
3935 #if VTK_MAJOR_VERSION <= 5 3940 imageReorient->SetFilteredAxis(1);
3941 imageReorient->FlipAboutOriginOn();
3943 imageReorient->Update();
3944 img = imageReorient->GetOutput();
3946 int actualExtent[6];
3949 if(extent[3]-extent[2] == 0)
3951 extent[2] = actualExtent[3]-extent[2];
3952 extent[3] = actualExtent[3]-extent[3];
3959 vtkSmartPointer<vtkImageReslice> slice = vtkSmartPointer<vtkImageReslice>::New();
3960 slice->SetOutputExtent(extent);
3961 #if VTK_MAJOR_VERSION <= 5 3962 slice->SetInput(img);
3964 slice->SetInputData(img);
3966 slice->SetOutputSpacing(img->GetSpacing());
3967 slice->SetOutputOrigin(img->GetOrigin());
3972 const int zAxis =
viewer->GetSliceOrientation();
3973 int axisToDisplace = 2;
3974 if(zAxis == vtkImageViewer2::SLICE_ORIENTATION_XZ)
3976 else if(zAxis == vtkImageViewer2::SLICE_ORIENTATION_YZ)
3979 emit
imageToPlot(slice->GetOutput(), axisToDisplace);
3985 viewer->GetInteractorStyle()->InvokeEvent(vtkCommand::ResetWindowLevelEvent);
3993 viewer->GetRenderer()->ResetCamera();
4006 menu->addSeparator()->setText(tr(
"Extensions"));
4009 menu->addAction(currAct);
4012 menu->addSeparator();
4017 menu->addSeparator();
4020 menu->addAction(currAct);
4024 menu->addMenu(currMenu);
4039 if(currentImgWindow == 0)
4043 if(currentWindow == 0)
4045 printError(
"Error in determining parent of action");
4049 vtkActorCollection *actors = currentWindow->
GetActors();
4052 size_t n = actors->GetNumberOfItems();
4054 actors->InitTraversal();
4055 for(
size_t j = 0; j < n; j ++)
4057 printDebug(
"Adding Generic Actor into scene.");
4058 vtkActor *currentActor = actors->GetNextItem();
4063 if(currentActor == item.parentActor)
4068 item.parentActor = currentActor;
4069 item.modelActor = vtkSmartPointer<vtkActor>::New();
4070 item.modelActor->ShallowCopy(currentActor);
4071 item.modelActor->GetProperty()->LightingOn();
4076 item.modelActor->Modified();
4079 vtkCommand::ModifiedEvent,
4081 SLOT( updateModelActor(vtkObject*,
unsigned long,
void*,
void*, vtkCommand*) ),
4086 printDebug(
"Transforming Actor to Image Space");
4093 qApp->processEvents();
4100 void milxQtImage::updateModelActor(vtkObject * obj,
unsigned long,
void * client_data,
void *, vtkCommand * command)
4102 vtkSmartPointer<vtkActor> actor = vtkActor::SafeDownCast(obj);
4107 if(actor == item.parentActor)
4109 item.modelActor->ShallowCopy(actor);
4110 item.modelActor->Modified();
4119 void milxQtImage::updateDisplay(QPointer<milxQtImage> img)
4131 orientAct->setChecked(img->isOriented());
4137 cursorAct->setChecked(img->isCrosshair());
4148 operateMenu->setTitle(QApplication::translate(
"Image",
"Operations", 0, QApplication::UnicodeUTF8));
4150 rescaleAct->setText(QApplication::translate(
"Image",
"Rescale Intensities", 0, QApplication::UnicodeUTF8));
4153 equaliseAct->setText(QApplication::translate(
"Image",
"Histogram Equalisation", 0, QApplication::UnicodeUTF8));
4156 computeContourAct->setText(QApplication::translate(
"Image",
"Compute Contour", 0, QApplication::UnicodeUTF8));
4159 smoothAct->setText(QApplication::translate(
"Image",
"Smooth via Anisotropic Diffusion", 0, QApplication::UnicodeUTF8));
4162 gaussianAct->setText(QApplication::translate(
"Image",
"Smooth via Gaussian Convolution", 0, QApplication::UnicodeUTF8));
4165 bilateralAct->setText(QApplication::translate(
"Image",
"Smooth via Bilateral Filter", 0, QApplication::UnicodeUTF8));
4168 medianAct->setText(QApplication::translate(
"Image",
"Smooth via Median", 0, QApplication::UnicodeUTF8));
4169 medianAct->setShortcut(tr(
"Shift+Alt+s"));
4171 gradMagAct->setText(QApplication::translate(
"Image",
"Gradient Magnitude", 0, QApplication::UnicodeUTF8));
4174 sobelAct->setText(QApplication::translate(
"Image",
"Sobel Edge Detection", 0, QApplication::UnicodeUTF8));
4175 sobelAct->setShortcut(tr(
"Alt+e"));
4177 cannyAct->setText(QApplication::translate(
"Image",
"Canny Edge Detection", 0, QApplication::UnicodeUTF8));
4178 cannyAct->setShortcut(tr(
"Shift+Alt+e"));
4180 laplacianAct->setText(QApplication::translate(
"Image",
"Apply Laplacian", 0, QApplication::UnicodeUTF8));
4183 highPassAct->setText(QApplication::translate(
"Image",
"Butterworth High-Pass Filter", 0, QApplication::UnicodeUTF8));
4186 normAct->setText(QApplication::translate(
"Image",
"Normalize", 0, QApplication::UnicodeUTF8));
4187 normAct->setShortcut(tr(
"Alt+n"));
4189 invertAct->setText(QApplication::translate(
"Image",
"Invert Intensities", 0, QApplication::UnicodeUTF8));
4192 relabelAct->setText(QApplication::translate(
"Image",
"Relabel", 0, QApplication::UnicodeUTF8));
4196 transformMenu->setTitle(QApplication::translate(
"Image",
"Transforms", 0, QApplication::UnicodeUTF8));
4198 matchAct->setText(QApplication::translate(
"Image",
"Match Information to ...", 0, QApplication::UnicodeUTF8));
4199 matchAct->setShortcut(tr(
"Shift+Alt+i"));
4201 matchHistAct->setText(QApplication::translate(
"Image",
"Match Histogram to ...", 0, QApplication::UnicodeUTF8));
4204 resampleSpacingAct->setText(QApplication::translate(
"Image",
"Resample to spacing ...", 0, QApplication::UnicodeUTF8));
4207 resampleAct->setText(QApplication::translate(
"Image",
"Resample Image to ...", 0, QApplication::UnicodeUTF8));
4210 resampleLabelAct->setText(QApplication::translate(
"Image",
"Resample as Labelled Image to ...", 0, QApplication::UnicodeUTF8));
4213 subsampleAct->setText(QApplication::translate(
"Image",
"Subsample Image", 0, QApplication::UnicodeUTF8));
4216 transformAct->setText(QApplication::translate(
"Image",
"Transform via File ...", 0, QApplication::UnicodeUTF8));
4219 maskAct->setText(QApplication::translate(
"Image",
"Mask Image with ...", 0, QApplication::UnicodeUTF8));
4220 maskAct->setShortcut(tr(
"Shift+Alt+m"));
4222 cropAct->setText(QApplication::translate(
"Image",
"Mask and Crop Image with ...", 0, QApplication::UnicodeUTF8));
4223 cropAct->setShortcut(tr(
"Shift+Alt+a"));
4225 checkerAct->setText(QApplication::translate(
"Image",
"Compare as Checkboard to ...", 0, QApplication::UnicodeUTF8));
4228 distMapAct->setText(QApplication::translate(
"Image",
"Distance Map", 0, QApplication::UnicodeUTF8));
4231 flipAct->setText(QApplication::translate(
"Image",
"Flip", 0, QApplication::UnicodeUTF8));
4232 flipAct->setShortcut(tr(
"Alt+f"));
4235 thresholdMenu->setTitle(QApplication::translate(
"Image",
"Thresholds", 0, QApplication::UnicodeUTF8));
4237 otsuAct->setText(QApplication::translate(
"Image",
"Otsu Threshold", 0, QApplication::UnicodeUTF8));
4238 otsuAct->setShortcut(tr(
"Alt+u"));
4240 otsuMultipleAct->setText(QApplication::translate(
"Image",
"Otsu Multiple Threshold", 0, QApplication::UnicodeUTF8));
4243 binaryAct->setText(QApplication::translate(
"Image",
"Binary Threshold", 0, QApplication::UnicodeUTF8));
4244 binaryAct->setShortcut(tr(
"Shift+Alt+b"));
4246 bandAct->setText(QApplication::translate(
"Image",
"Threshold Outside Band", 0, QApplication::UnicodeUTF8));
4247 bandAct->setShortcut(tr(
"Alt+t"));
4249 aboveAct->setText(QApplication::translate(
"Image",
"Threshold Above", 0, QApplication::UnicodeUTF8));
4250 aboveAct->setShortcut(tr(
"Shift+Alt+a"));
4252 belowAct->setText(QApplication::translate(
"Image",
"Threshold Below", 0, QApplication::UnicodeUTF8));
4253 belowAct->setShortcut(tr(
"Shift+Alt+b"));
4256 vectorMenu->setTitle(QApplication::translate(
"Image",
"Complex/Vector/4D Imaging", 0, QApplication::UnicodeUTF8));
4259 vectorMagnitudeAct->setText(QApplication::translate(
"Image",
"Display Magnitude", 0, QApplication::UnicodeUTF8));
4262 vectorComponentAct->setText(QApplication::translate(
"Image",
"Display Component ...", 0, QApplication::UnicodeUTF8));
4265 pseudoImageAct->setText(QApplication::translate(
"Image",
"Display Pseudo-Image", 0, QApplication::UnicodeUTF8));
4268 vectorFieldAct->setText(QApplication::translate(
"Image",
"Display Vector/Tensor Field", 0, QApplication::UnicodeUTF8));
4271 streamLinesAct->setText(QApplication::translate(
"Image",
"Display Streamlines from Slice", 0, QApplication::UnicodeUTF8));
4276 levelAct->setText(QApplication::translate(
"Image",
"Auto-Level Display", 0, QApplication::UnicodeUTF8));
4277 levelAct->setShortcut(tr(
"Alt+o"));
4279 overlayAct->setText(QApplication::translate(
"Image",
"Overlay Labelled Image from ...", 0, QApplication::UnicodeUTF8));
4282 overlayContourAct->setText(QApplication::translate(
"Image",
"Overlay Labelled Image as Contour from ...", 0, QApplication::UnicodeUTF8));
4285 blendAct->setText(QApplication::translate(
"Image",
"Blend Image with ...", 0, QApplication::UnicodeUTF8));
4286 blendAct->setShortcut(tr(
"Shift+Alt+b"));
4288 volRenderAct->setText(QApplication::translate(
"Image",
"Display as Volume Rendering", 0, QApplication::UnicodeUTF8));
4291 histogramAct->setText(QApplication::translate(
"Image",
"Display Histogram", 0, QApplication::UnicodeUTF8));
4294 surfacePlotAct->setText(QApplication::translate(
"Image",
"Display Slice Surface Plot", 0, QApplication::UnicodeUTF8));
4297 surfaceAct->setText(QApplication::translate(
"Image",
"Display Iso-surface", 0, QApplication::UnicodeUTF8));
4300 polyDataAct->setText(QApplication::translate(
"Image",
"Generate Polygonal Data", 0, QApplication::UnicodeUTF8));
4304 infoAct->setText(QApplication::translate(
"Image",
"Image Information", 0, QApplication::UnicodeUTF8));
4305 infoAct->setShortcut(tr(
"Alt+i"));
4307 interpolateAct->setText(QApplication::translate(
"Image",
"Interpolation", 0, QApplication::UnicodeUTF8));
4312 orientAct->setText(QApplication::translate(
"Image",
"Apply Orientation", 0, QApplication::UnicodeUTF8));
4313 orientAct->setShortcut(tr(
"Shift+Alt+o"));
4317 resliceAct->setText(QApplication::translate(
"Image",
"3D Slice View Mode", 0, QApplication::UnicodeUTF8));
4321 #if VTK_MAJOR_VERSION <= 5 4325 cursorAct->setText(QApplication::translate(
"Image",
"Show Cursor", 0, QApplication::UnicodeUTF8));
4326 cursorAct->setShortcut(tr(
"Shift+Alt+c"));
4330 #if (ITK_REVIEW || ITK_VERSION_MAJOR > 3) 4347 connect(
this, SIGNAL(mouseEvent(QMouseEvent*)),
this, SLOT(userEvent(QMouseEvent*)));
4352 #if (ITK_REVIEW || ITK_VERSION_MAJOR > 3) 4375 connect(
maskAct, SIGNAL(triggered()),
this, SLOT(
mask()));
4378 connect(
flipAct, SIGNAL(triggered()),
this, SLOT(
flip()));
4385 connect(
otsuAct, SIGNAL(triggered()),
this, SLOT(
otsu()));
4397 #if (ITK_REVIEW || ITK_VERSION_MAJOR > 3) 4398 connect(
cropAct, SIGNAL(triggered()),
this, SLOT(
crop()));
4399 connect(
overlayAct, SIGNAL(triggered()),
this, SLOT(overlay()));
4402 connect(
blendAct, SIGNAL(triggered()),
this, SLOT(
blend()));
4409 #if VTK_MAJOR_VERSION > 5 4410 connect(
resliceAct, SIGNAL(triggered()),
this, SLOT(resliceMode()));
4429 contextMenu->setTitle(QApplication::translate(
"MainWindow",
"Imaging", 0, QApplication::UnicodeUTF8));
4444 contextMenu->addSeparator()->setText(tr(
"Display"));
4545 if(currentEvent->source() ==
this)
4549 if(currentEvent->spontaneous())
4550 currentEvent->ignore();
4552 QList<QUrl> urlsList = currentEvent->mimeData()->urls();
4553 QString tmp, typeString = currentEvent->mimeData()->text();
4555 for(
int j = 0; j < urlsList.size(); j ++)
4557 if(urlsList[j].isValid())
4560 tmp = urlsList[j].path().remove(0,1);
4562 tmp = urlsList[j].path();
4564 printInfo(
"Dropped Path into Image: " + tmp);
4568 currentEvent->acceptProposedAction();
4569 if(currentEvent->proposedAction() == Qt::MoveAction)
4572 #if (ITK_REVIEW || ITK_VERSION_MAJOR > 3) 4573 if(currentEvent->proposedAction() == Qt::LinkAction)
4587 printInfo(
"Setting up image for Annotation");
4588 interactor->Initialize();
4590 double imageBounds[6], imgCenter[3];
4593 double length = imageBounds[1]-imageBounds[0]/10;
4596 lineWidget = vtkSmartPointer<vtkLineWidget2>::New();
4604 vtkDistanceRepresentation::SafeDownCast(
distanceWidget->GetRepresentation())->SetLabelFormat(
"%-#6.3g mm");
4612 angleWidget = vtkSmartPointer<vtkAngleWidget>::New();
4617 sphereRep = vtkSmartPointer<vtkSphereRepresentation>::New();
4618 sphereRep->SetRepresentationToWireframe();
4626 sphereWidget = vtkSmartPointer<vtkSphereWidget2>::New();
4633 sphereRep->GetSphereProperty()->SetColor(0.9, 0.9, 1.0);
4635 vtkSmartPointer<vtkPolyData> sphere = vtkSmartPointer<vtkPolyData>::New();
4639 boxWidget = vtkSmartPointer<vtkBoxWidget2>::New();
4644 vtkSmartPointer<vtkBoxRepresentation> boxRepresentation = vtkSmartPointer<vtkBoxRepresentation>::New();
4645 boxRepresentation->SetPlaceFactor( 1 );
4646 boxRepresentation->PlaceWidget(sphere->GetBounds());
4647 boxWidget->SetRepresentation(boxRepresentation);
4650 double actorBounds[6], center[3];
4652 sphere->GetBounds(actorBounds);
4653 center[0] = (actorBounds[0] + actorBounds[1])/2.0;
4654 center[1] = (actorBounds[2] + actorBounds[3])/2.0;
4655 center[2] = (actorBounds[4] + actorBounds[5])/2.0;
4656 planeWidget = vtkSmartPointer<vtkPlaneWidget>::New();
4677 planeWidget->SetOrigin(actorBounds[0],actorBounds[2],center[2]);
4678 planeWidget->SetPoint1(actorBounds[1],actorBounds[2],center[2]);
4679 planeWidget->SetPoint2(actorBounds[0],actorBounds[3],center[2]);
4687 exts = QString(openMedImageExts.c_str()) +
";;" + QString(openImageExts.c_str()) +
";;" + QString(openOtherImageExts.c_str());
4688 QSettings settings(
"Shekhar Chandra",
"milxQt");
4689 QString path = settings.value(
"recentPath").toString();
4690 QFileDialog *fileOpener =
new QFileDialog(
this);
4691 QString filename = fileOpener->getOpenFileName(
this,
4692 tr(labelForDialog.toStdString().c_str()),
4694 tr(exts.toStdString().c_str()) );
QAction * scaleAct
Action for the scale bar of the display.
void printWarning(QString msg)
Warning message wrapper for console.
QMenu * transformsMenu()
Return the transforms menu with the milxQtImage class ordering. This is for the benefit of derived cl...
void checkerBoard(QString filename="", int numberOfSquares=0)
Tiles another image with the current image using alternating squares for comparison. See generateCheckerBoard() for more info.
vtkLookupTable * GetLookupTable()
Get the lookup table of the colours in display window.
int defaultView
Default view for data (default is axial)
void highpass()
Applies Butterworth high pass filter to image.
bool logScale
Using custom scalar bar?
void printError(QString msg)
Error message wrapper for console.
void reset()
Update data internally and refresh display.
virtual void updateCoords(vtkObject *obj)
Picks the coordinates and pixel value from the current mouse position in the window.
QAction * blendAct
Action for blending images.
QAction * matchAct
Action for matching info of image to another image.
static itk::SmartPointer< TImage > ThresholdImage(itk::SmartPointer< TImage > img, float outsideValue, float belowValue, float aboveValue)
Generates an image with the intensities below and above a certain level thresholded (capped) to the o...
vtkSmartPointer< vtkImageData > imageData
Points to the current VTK Image Data, Smart Pointer.
bool isFloatingPointImage()
Returns true if image is a floating point (float) image.
QAction * overlayAct
Action for overlaying labelled image.
void generateVoxelisedSurface(vtkSmartPointer< vtkPolyData > surfaceToVoxelise, double *bounds=NULL, double *spacing=NULL)
Converts or Voxelises a surface (vtkPolyData) to an image.
virtual void showCrosshair(const bool quietly=false)
Show the cursor/crosshair for marking depending on action. Image must be generated before calling...
QAction * orientAct
Orient image?
void sobelEdges()
Computes the Sobel edge detection of the image and displays it.
QAction * histogramAct
Action for displaying histogram.
QAction * saveViewFileAct
Save camera view to file.
bool eightbit
Using eightbit data?
virtual void scaleDisplay(const bool forceDisplay=false)
Toggles the scale bar display.
QMenu * viewMenu
Context Menu.
vtkSmartPointer< vtkBoxWidget2 > boxWidget
Used for measuring angles.
void bilateral()
Computes the Bilateral smoothing of the image and displays it.
void anisotropicDiffusion()
Computes the anisotropic diffusion (smoothing) of the image and displays it.
QAction * cropAct
Action for auto cropping image.
QAction * lightingAct
Action for two-sided lighting of the display.
itkEventQtObserver::Pointer observeProgress
Observer for the Qt event loop.
int currentView
Current view for data.
void contextMenuEvent(QContextMenuEvent *event)
The context menu setup member.
QMenu * basicContextMenu()
Return the basic context menu with the milxQtImage class ordering. This is for the benefit of derived...
QActionGroup * windowActionGroup
used for the custom menu
virtual vtkRenderWindowInteractor * GetVTKInteractor()
Get the interactor associated with the view rendering.
void setName(const QString filename)
Set the name of the data.
QList< QAction * > extActionsToAdd
Extension actions to add.
void createConnections()
Create the connections for context menu etc.
QAction * relabelAct
Action for relabelling image.
milxQtImage(QWidget *theParent=0, bool contextSystem=true)
The standard constructor.
void invertIntensity()
Computes the inverse intensities of the image and displays it.
vtkActorCollection * GetActors()
Get all the actors in the render window.
void imageToVectorField(vectorImageType::Pointer, floatImageType::Pointer, int, float)
Emit signal to compute image to vector field process.
vtkSmartPointer< vtkContourWidget > contourWidget
contour interaction
static itk::SmartPointer< TImage > RelabelImage(itk::SmartPointer< TImage > labelledImg)
Returns a labelled image with labelled values relabelled consecutively based on connectivity.
vtkSmartPointer< vtkRenderer > renderer
Renderer for the data.
void SetIntensityLevel(double level)
Set the level for the image intensity tranfer function.
void AddActor(vtkSmartPointer< vtkProp > actor)
Add a VTK actor to this window.
This class represents the MILX Qt Render Window Display object using QVTK.
QAction * cannyAct
Action for canny edges of image.
vtkSmartPointer< vtkAngleWidget > angleWidget
Used for measuring angles.
void imageToVolume(vtkSmartPointer< vtkImageData >, bool)
Emit signal to show the image as a volume.
virtual QString strippedNamePrefix()
Returns the stripped (path removed) name of the data with "Generic" prefix.
vtkSmartPointer< vtkLookupTable > lookupTable
Lookup table for the shapes/images, base class is used to allow references to different look up table...
vtkSmartPointer< vtkImageViewer3 > viewer
VTK Viewer handler, Smart Pointer.
void median()
Computes the median image and displays it.
QAction * otsuMultipleAct
Otsu Threshold.
void createActions()
Create the actions for context menu etc.
QAction * viewZY
Change view to zy-plane (Coronal)
This class represents the MILX Qt Image Display object using VTK.
void component(int index=-1)
Shows the vector image as a scalar image given component index.
void normalize()
Computes the normalization of the image and displays it.
QAction * pseudoImageAct
Action for displaying vector/tensor fields as a pseudo image.
QAction * vectorMagnitudeAct
Action for displaying magnitude of vector images.
bool loaded
Loaded Image from file?
void resize(double outputSpacing=0.0)
Resizes image to spacing given. Currently only does isotropic.
static itk::SmartPointer< TImage > CheckerBoard(itk::SmartPointer< TImage > img, itk::SmartPointer< TImage > imgToCheckerBoard, const int numberOfSquares=0)
Generates a checker board pattern where each box alternates between two images. Ideal for comparison ...
void surfacePlot()
Surface plot of slice.
vtkSmartPointer< vtkBiDimensionalWidget > biDirectionWidget
Used for measuring cross distances.
floatImageType::Pointer imageFloat
Up to date floating point image data.
vtkSmartPointer< vtkMatrix4x4 > transformMatrix
Transform matrix for actor(s)
void gradientMagnitude()
Computes the gradient magnitude of the image and displays it.
virtual void contour()
Draw contour interactively on images.
QMenu * contextMenu
Context Menu.
virtual void disableCrosshair()
removes the cursor/crosshair.
void setLevel(int level)
Set window level the display to proportion of maxValue.
virtual void viewToZXPlane()
Change view to zx-plane.
This class represents the MILX Qt File I/O object using VTK/ITK/Qt.
QString strippedName()
Returns the stripped (path removed) name of the data.
QAction * cursorAct
Show cursor?
void thresholdAbove(float value=0, float level=0)
Threshold the image for all values above a given value.
vtkSmartPointer< vtkOrientationMarkerWidget > humanGlyph
Glyph for showing equivalent view on human.
QAction * flipAct
Action for flipping image.
void scale(float scaling)
scales the intensities of current images.
QAction * distMapAct
Action for distance map of image.
vtkSmartPointer< vtkImageAccumulate > hist
Histogram filter, allocated on histogram() call.
void vectorField(int subsampleFactor=0, float scaling=0.0)
Converts the vector image to a vector field.
virtual void createMenu(QMenu *menu)
Create the menu for the data in this object. Used for context menu and file menus.
QAction * surfacePlotAct
Action for displaying surface plot.
QAction * resliceAct
Reslice mode?
static itk::SmartPointer< TImage > SubtractImages(itk::SmartPointer< TImage > img1, itk::SmartPointer< TImage > img2)
Subtracts image 2 from image 1, returning the result.
void volumeRendering()
Display current image as volume rendering.
static itk::SmartPointer< TImage > GradientMagnitude(itk::SmartPointer< TImage > img)
Generates an image with the gradient magnitude of the given image.
void blend(QString filename="", float opacity=-1.0)
Display a blend of the current image with another image.
void modified(vtkSmartPointer< vtkImageActor >)
Emit signal to allow updating of image actors if present.
void dropEvent(QDropEvent *event)
Part of the Drag and Drop feature members. Opens the dropped files.
void threshold(float value=0, float blevel=0, float alevel=0)
Threshold the image for all values between a band to a given value.
QAction * laplacianAct
Action for Laplacian of image.
void setDisplayData(QPointer< milxQtImage > newImg)
Shares the milxQtImage data to current image. You will need to call generate image after this...
void rescale()
Rescaled the intensities of an image to specified new max and min values.
vtkImageActor * GetImageActor()
Returns the internal image actor used for display.
QAction * humanAct
Show human view orientation glyph?
void multiply(milxQtImage *img)
Multiplies img to current image.
void SetTransform(vtkSmartPointer< vtkTransform > transform)
Sets the transform for the image that will be generated. Must pass a vtkTransform objects...
void transform(QString filename="", QString refImgFilename="", bool inverse=false)
Transforms current image given ITK transform file.
double stddevValue
Std deviation data value currently held.
void mask(QString filename="")
Masks current image with another image.
void setDeletableOnClose(bool delOnClose)
Set if the window deletable on close. Default is true.
QList< QMenu * > menusToAdd
Context Menu's to add.
QAction * belowAct
Threshold from below.
void applyOrientDisplay(const bool quietly=false)
Toggles applying the orientation matrix of the image.
virtual void SetupWidgets(vtkRenderWindowInteractor *interactor)
Update the interactor so that the widgets are usable. Resizing widges for image objects.
QAction * bandAct
Threshold inbetween band.
QAction * streamLinesAct
Action for displaying stream lines.
QAction * otsuAct
Otsu Threshold.
QAction * backgroundAct
Action for axes of the display.
static itk::SmartPointer< TImage > ThresholdAboveImage(itk::SmartPointer< TImage > img, float outsideValue, float aboveValue)
Generates an image with the intensities above a certain level thresholded (capped) to the outsideValu...
void interpolateDisplay(const bool quietly=false)
Toggles interpolation.
bool track
track the coordinates during user interaction
double GetIntensityLevel()
Get the level for the image intensity tranfer function.
vtkSmartPointer< vtkDistanceWidget > distanceWidget
Used for measuring distances.
void imageToPseudoImage(vectorImageType::Pointer)
Emit signal to compute image to pseudo-image process.
vtkSmartPointer< vtkLineWidget2 > lineWidget
Used for drawing lines.
QAction * volRenderAct
Action for volume rendering.
vectorImageType::Pointer GetVectorImage()
Returns the internal vector image data. Unlike the other Get*Image() members, the return value can be...
QAction * matchHistAct
Action for matching histogram of image.
void laplacian()
Computes the Laplacian of the image and displays it.
QString prefix
Prefix of the data.
QActionGroup * viewGroup
Grouping for check boxes.
void printDebug(QString msg)
Debug message wrapper for console.
QAction * contourPolyDataAct
Save contour surface points as polydata.
virtual void updateLookupTable()
Sets the necessary LUTs to model view.
bool is32BitImage()
Returns true if image is an 32-bit (int) image.
bool appendedData
Appended image data?
QAction * infoAct
Action for displaying information about the image.
static std::string ImageOrientation(itk::SmartPointer< TImage > img)
Returns the orientation flag of an image.
static itk::SmartPointer< TImage > GaussianSmooth(itk::SmartPointer< TImage > img, const float variance)
Generates the Gaussian smoothing (by convolution) of an image using the variance provided.
QAction * actionDefault
Default colours.
void polyData()
Converts the image to polygonal data. Ideally suited for any type of image.
QMenu * vectorMenu
Vector Menu.
QAction * contourAct
Action for contouring surface points using Dijkstras algorithm.
QAction * checkerAct
Action for checkerboard of image.
static itk::SmartPointer< TImage > ThresholdBelowImage(itk::SmartPointer< TImage > img, float outsideValue, float aboveValue)
Generates an image with the intensities below a certain level thresholded (capped) to the outsideValu...
void updateSlice(vtkObject *obj)
Updates the display of the slice in the window.
void Render()
Force Render or Update of the display.
QMenu * transformMenu
Transform Menu.
void crop(QString filename="")
Masks and crops the current image with another image.
static itk::SmartPointer< TImage > Laplacian(itk::SmartPointer< TImage > img)
Generates an Laplacian image from the input image.
void otsuMultiple(int bins=0, int labels=0)
Otsu Multiple Threshold the image for all values between a band to a given level. ...
bool imported
Imported before?
void setDefaultOrientation(int orientMode)
Change orientation mode to one of the supported standards. Default: Radiological. ...
static itk::SmartPointer< TImage > ResizeImage(itk::SmartPointer< TImage > img, typename TImage::SizeType imgSize)
Resizes current image using current spacing.
QAction * aboveAct
Threshold from above.
void resample(QString filename="")
Resamples current image to another image.
rgbImageType::Pointer GetRGBImage()
Returns the internal RGB image data.
vtkImageMapToWindowLevelColors * GetWindowLevel()
Returns the internal image window levels data used for display.
void convolve(milxQtImage *img)
Convolves img to current image.
QMenu * thresholdMenu
Threshold Menu.
virtual void enableCrosshair()
Enables the cursor/crosshair for marking. Image must be generated before calling. ...
void setView(int viewMode)
Change view to view mode identified by number. 0-axial, 1-coronal, 2-sagittal.
QAction * transformAct
Action for transforming image.
QAction * levelAct
Action for auto-levelling gamma for display.
static itk::SmartPointer< TImage > MatchHistogram(itk::SmartPointer< TImage > img, itk::SmartPointer< TImage > imgToMatch, const int bins=128)
Changes the image gray levels to match histogram of image provided.
QAction * normAct
Action for normalization of image.
bool isOriented()
Returns true if orientation is applied to the display of the image.
QAction * binaryAct
Binary Threshold.
void generateImage(const bool quietly=false)
Assigns the array data to the image and setups up the viewer.
QMenu * vectorsMenu()
Return the vector imaging menu with the milxQtImage class ordering. This is for the benefit of derive...
bool viewerSetup
has the viewer/window been setup (only done initial so is to not disturb users settings) ...
QList< QAction * > actionsToAppend
Context actions to append.
QAction * contourNodePolyDataAct
Save contour surface nodes as polydata.
void thresholdBelow(float value=0, float level=0)
Threshold the image for all values below a given value.
bool isCrosshair()
Returns true if cursor shown to the display of the image.
QAction * equaliseAct
Action for contouring image.
QAction * sobelAct
Action for sobel edges of image.
double meanValue
Other Variables.
QAction * refreshAct
Action for refreshing the display.
bool integer
Using integer data?
QAction * overlayContourAct
Action for overlaying labelled image as contour.
static itk::SmartPointer< TImage > Bilateral(itk::SmartPointer< TImage > img, const float sigmaRange, const float sigmaSpatial)
Generates the (non-linear) Bilateral smoothing of an image using the sigmas provided.
QAction * interpolateAct
Interpolate image?
static itk::SmartPointer< TImage > SobelEdges(itk::SmartPointer< TImage > img)
Generates an image with Sobel edges, i.e. uses the Sobel edge detection on the input image...
QAction * resampleAct
Action for resampling image.
QAction * contourInitAct
Load contour surface points from polydata.
bool scaleBefore
scale displayed?
QAction * highPassAct
Action for high pass filtering of image.
Represents an image (i.e. an regular rectangular array with scalar values) and their common operation...
void enableActionBasedOnView()
Enables the view actions corresponding to current view set.
double minValue
min value in image
QAction * gradMagAct
Action for gradient magnitude of image.
bool openImage(const QString filename, vtkImageData *data)
Opens an image file, which is any of the following: JPEG, PNG, DICOM, TIFF, NIFTI, HDR etc.
static itk::SmartPointer< TImage > HistogramEqualisation(itk::SmartPointer< TImage > img, float alpha=0.3, float beta=0.3, float radius=5)
Generates an image with the intensities after histogram equalisation. Defaults to classic histogram e...
void distanceMap(bool signedDistance=true, bool inside=false)
Computes the distance map of the image and displays it.
void binaryThreshold(float value=0, float blevel=0, float alevel=0)
Binary Threshold the image for all values between a band to a given value.
void cannyEdges()
Computes the Canny edge detection of the image and displays it.
QMenu * contourMenu
Contour Menu.
void imageInformation()
Displays the origin and other important information about the image (not the displayed image...
void SetRenderer(vtkRenderer *rnder)
Assigns a VTK Renderer object.
static vtkSmartPointer< vtkImageData > ApplyOrientationToVTKImage(vtkSmartPointer< vtkImageData > img, itk::SmartPointer< TImage > refImage, vtkSmartPointer< vtkMatrix4x4 > &transformMatrix, const bool labelledImage, const bool flipY=true)
Applies orientation/direction and origin to a VTK image from a reference image.
QList< ModelActorItem > modelActors
Model actors being displayed in image view.
void imageToSurface(vtkSmartPointer< vtkImageData >, const float)
Emit signal to compute image to surface process.
charImageType::Pointer imageChar
Up to date 8-bit greyscale image data.
QAction * resetAct
Action for refreshing the display.
QAction * gaussianAct
Action for Gaussian smoothing of image.
bool isVectorImage()
Returns true if image is a vector image.
QMenu * colourMapMenu
Colour map menu.
QAction * subsampleAct
Action for downsampling image.
void trackView(milxQtImage *windowToTrack, ViewType viewTo)
Enables tracking of the view (axial etc.) to imgToTrack provided.
QAction * rescaleAct
Action for contouring image.
bool usingVTKImage
using VTK image data?
virtual void viewToZYPlane()
Change view to zy-plane.
virtual void disableScale()
Disables the scale bar display.
void linkProgressEventOf(vtkObject *obj)
Link the progress of filters etc to keep the UI responsive.
void magnitude()
Shows the vector image as a scalar image given by the magnitude of the vectors.
double maxValue
max value in image
QAction * saveViewAct
Save camera view.
bool vectorised
Using Vector image data?
void relabel()
Relabel the objects of a labelled image based on connectivity in consecutive order.
QAction * viewXY
Change view to xy-plane (Axial)
void imageToPlot(vtkSmartPointer< vtkImageData >, int)
Emit signal to show the image as a plot.
QAction * vectorFieldAct
Action for displaying vector/tensor fields.
QAction * resampleSpacingAct
Action for resampling image based on spacing.
virtual void enableScale(QString title="", const bool quiet=false, double minRange=0.0, double maxRange=0.0, int noOfLabels=3)
Enable scale bar display with the title provided.
QAction * invertAct
Action for invert intensity of image.
vtkSmartPointer< vtkPlaneWidget > planeWidget
Used for drawing planes.
void setupEvents()
Executes common events setup and connections code for image viewing.
void lighting()
Toggles two sided lighting in display.
static itk::SmartPointer< TImage > MatchInformation(itk::SmartPointer< TImage > img, itk::SmartPointer< TImage > imgToMatch, bool originOnly=false)
Changes the image info to match that of provided image. By default, only the spacing, region and origin are changed.
QString getOpenFilename(const QString labelForDialog="Select Image", QString exts="")
Use the QFileDialog to get an image filename.
QMenu * thresholdsMenu()
Return the thresholds menu with the milxQtImage class ordering. This is for the benefit of derived cl...
virtual ~milxQtImage()
The standard destructor.
void imageToStreamLines(vectorImageType::Pointer, floatImageType::Pointer)
Emit signal to compute image streamlines of vector field process. Every pixel in the float image is u...
bool flipped
Flip for display?
void imageToPolyData(vtkSmartPointer< vtkImageData >)
Emit signal to compute image to poly data process.
QList< QAction * > actionsToAdd
Context actions to add.
charImageType::Pointer GetCharImage()
Returns the internal unsigned char image data.
void updateData(const bool orient=true)
Ensures the internal visualisation data is up to date.
void setupHumanGlyph(vtkSmartPointer< vtkMatrix4x4 > mat=NULL)
Setup the human orientation glyph even if some transform if present between glyph and view...
QAction * medianAct
Action for median smoothing of image.
vtkSmartPointer< vtkSphereWidget2 > sphereWidget
Used for measuring angles.
size_t actualNumberOfDimensions
All images loaded as 3D images or 3D vector images, this shows actual dimension.
static itk::SmartPointer< TImage > AddImages(itk::SmartPointer< TImage > img1, itk::SmartPointer< TImage > img2)
Adds image 1 to image 2, returning the result.
void histogramEqualisation()
Rescale the intensities of an image based on histogram equalisation.
QAction * viewZX
Change view to zx-plane (Sagittal)
virtual void customOperation()
Custom operation, data dependent for viewing in unified environment.
void modified(QPointer< milxQtImage >)
Emit signal to send updated image data. Used for updating dependent displays.
static itk::SmartPointer< TImage > FlipImage(itk::SmartPointer< TImage > img, bool xAxis=false, bool yAxis=true, bool zAxis=false, bool aboutOrigin=true)
Generates an image with axes flipped. Currently flips the y-axis as default, but can do other axes al...
void updateTrackedView(vtkObject *obj)
Updates the display of the slice in the window according to view tracking.
void done(int value)
Send signal that computation is done. Value carries the progress,.
void pseudoImage()
Converts the vector image to a pseudo-image, where each vector component is 'coloured'.
vtkSmartPointer< vtkScalarBarActor > scale
Scale for the display.
void subsample(size_t xSampleFactor=0, size_t ySampleFactor=0, size_t zSampleFactor=0)
Downsamples current image by factors given.
static itk::SmartPointer< TImage > DuplicateImage(itk::SmartPointer< TImage > img)
Duplicates the image into a new image.
floatImageType::Pointer GetFloatImage()
Returns the internal float image data.
void setView(int viewMode)
Change view to view mode identified by number. 0-axial, 1-coronal, 2-sagittal.
QAction * computeContourAct
Action for contouring image.
QAction * maskAct
Action for resampling image.
static itk::SmartPointer< TImage > ScaleVectorImage(itk::SmartPointer< TImage > img, float scaling, int numberOfComponents)
Scales each component of the vector image intensities by scaling factor and returns the result...
bool isRGBImage()
Returns true if image is an RGB (3-vector unsigned char image) image.
QAction * polyDataAct
Action for image to poly data.
void flip(bool xAxis=false, bool yAxis=false, bool zAxis=false, bool aboutOrigin=true)
Flips the image and displays it. If all the arguments are false, then axes will be asked for using GU...
vtkSmartPointer< vtkSphereRepresentation > sphereRep
Sphere for widgets.
void setData(QPointer< milxQtImage > newImg, const bool forceDeepCopy=false)
Assigns the milxQtImage data to current image. You will need to call generate image after this...
void setDefaultView(int viewMode)
Change default view to view mode identified by number. 0-axial, 1-coronal, 2-sagittal.
static itk::SmartPointer< TImage > CannyEdges(itk::SmartPointer< TImage > img, float variance, float lowerThreshold, float upperThreshold)
Generates an Canny edge image from the input image.
void surface(const float value=numeric_limits< float >::max())
Converts the image to a surface using the Marching Cubes algorithm. Ideally suited for binary images...
vectorImageType::Pointer imageVector
Up to date vector image data.
static itk::SmartPointer< itk::Image< float, TImage::ImageDimension > > Normalization(itk::SmartPointer< TImage > img)
Generates an image which is statistically normalised so having pixel values between -1 and 1...
void add(milxQtImage *img)
Adds img to current image.
static itk::SmartPointer< TImage > BlankImage(typename TImage::PixelType value, typename TImage::SizeType imgSize)
Creates an empty image filled with value given.
void refresh()
Refresh the display of the model including widgets. Camera remains as is.
void gaussianSmooth()
Computes the Gaussian smoothing of the image and displays it.
void autoLevel(float percentile=0.99)
Auto window level the display. Uses Otsu threshold value.
void createConnections()
Create the connections for context menu etc.
intImageType::Pointer imageInt
Up to date 32-bit greyscale image data.
bool is8BitImage()
Returns true if image is an 8-bit (unsigned char) image.
void printInfo(QString msg)
Info message wrapper for console.
bool useDefaultView
Using log scalar map?
void streamLines()
Converts the vector image to a series of stream lines which all start at the current slice being view...
vtkSmartPointer< vtkEventQtSlotConnect > Connector
VTK Events to slots convertor.
void SetIntensityWindow(double window)
Set the window for the image intensity tranfer function.
QAction * smoothAct
Action for smoothing of image.
static itk::SmartPointer< TImage > InvertIntensity(itk::SmartPointer< TImage > img, float maxValue)
Generates an image with the intensities reversed based on the max pixel value.
void subtract(milxQtImage *img)
Subtracts img from current image.
virtual void viewToXYPlane()
Change view to xy-plane.
bool volume
is the image a volume?
QAction * resampleLabelAct
Action for resampling image.
static itk::SmartPointer< TImage > Median(itk::SmartPointer< TImage > img, const int radius)
Generates the (non-linear) median filtering (smoothing) of an image of given neighbourhood radius...
void working(int value)
Send signal that computation is in progress. Value carries the progress,.
vtkSmartPointer< vtkScalarBarWidget > scalarBar
Scalar Bar Widget for the display.
void zeros(const unsigned long xSize, const unsigned long ySize, const unsigned long zSize, milxQtImage *refImage=NULL)
Creates image of zeros of size given.
int getView()
Return current view mode identified by number. 0-axial, 1-coronal, 2-sagittal.
void histogram(int bins=256, float belowValue=0, float aboveValue=255, bool plotHistogram=true)
Computes the histogram of the image and prints info found.
void setDefaultOrientation(int orientMode)
Change orientation mode to one of the supported standards. Default: Radiological. ...
QMenu * windowPropertiesMenu
Context Menu.
double GetIntensityWindow()
Get the window for the image intensity tranfer function.
void setSlice(int slice)
Sets the slice of the volume to slice value given.
void refresh()
Refresh display.
intImageType::Pointer GetIntImage()
Returns the internal unsigned char image data.
QAction * surfaceAct
Action for image to surface.
QMenu * operationsMenu()
Return the operations menu with the milxQtImage class ordering. This is for the benefit of derived cl...
void tableToPlot(vtkSmartPointer< vtkTable >, QString)
Emit signal to show the table as a plot.
void imageToTensorField(vectorImageType::Pointer, floatImageType::Pointer, int, float)
Emit signal to compute image to tensor field process.
QStatusBar * updateBar
Pointer to bar, not allocated or deleted. To be passed to only.
QList< QMenu * > menusToAppend
Context Menu's to append.
static itk::SmartPointer< TImage > SubsampleImage(itk::SmartPointer< TImage > img, typename TImage::SizeType factors)
Subsamples or shrinks the current image using the factors provided.
QAction * vectorComponentAct
Action for displaying components of vector images.
QAction * loadViewAct
Load camera view.
ViewType viewToTrack
In tracking mode, what slice to show.
vtkSmartPointer< vtkPointPicker > dataPicker
For determining coordinates and points from the window.
void matchHistogram(milxQtImage *imageToMatch)
Matches the histogram of another image to the current image. See generateMatchedHistogram() for more ...
void disableOrient()
Disables orientation marker.
void otsu(int bins=0)
Otsu Threshold the image for all values between a band to a given level.
QAction * bilateralAct
Action for bilateral smoothing of image.
QMenu * operateMenu
Operate Menu.
void matchInfo(milxQtImage *imageToMatch)
Matches the info of another image to the current image. See generateMatchedInformation() for more inf...
void resampleLabel(QString filename="")
Resamples current image as a labelled image (toavoid interpolation artefacts) to another image...
bool isInterpolated()
Returns true if image display is interpolated.
QAction * loadViewFileAct
Load camera view to file.
rgbImageType::Pointer imageRGB
Up to date 32-bit image data (used only internally atm)