| 42 | std::mutex testMutex; |
| 43 | |
| 44 | itk::ITK_THREAD_RETURN_TYPE ThreadMethod(ThreadData *threadData) |
| 45 | { |
| 46 | if (nullptr == threadData) |
| 47 | return itk::ITK_THREAD_RETURN_DEFAULT_VALUE; |
| 48 | |
| 49 | mitk::Image::Pointer im = threadData->Data; |
| 50 | |
| 51 | int nrSlices = im->GetDimension(2); |
| 52 | |
| 53 | std::uniform_int_distribution<> distrib(1, 1000000); |
| 54 | |
| 55 | // Create randomly a PixelRead- or PixelWriteAccessor for a slice and access all pixels in it. |
| 56 | try |
| 57 | { |
| 58 | threadData->RandGenMutex.lock(); |
| 59 | auto even = distrib(threadData->RandGen) % 2; |
| 60 | auto slice = distrib(threadData->RandGen) % nrSlices; |
| 61 | threadData->RandGenMutex.unlock(); |
| 62 | |
| 63 | if (even) |
| 64 | { |
| 65 | testMutex.lock(); |
| 66 | mitk::ImageDataItem *iDi = im->GetSliceData(slice); |
| 67 | testMutex.unlock(); |
| 68 | while (!iDi->IsComplete()) |
| 69 | { |
| 70 | } |
| 71 | |
| 72 | // MITK_INFO << "pixeltype: " << im->GetPixelType().GetComponentTypeAsString(); |
| 73 | |
| 74 | if ((im->GetPixelType().GetComponentTypeAsString() == "short") && (im->GetDimension() == 3)) |
| 75 | { |
| 76 | // Use pixeltype&dimension specific read accessor |
| 77 | |
| 78 | int xlength = im->GetDimension(0); |
| 79 | int ylength = im->GetDimension(1); |
| 80 | |
| 81 | mitk::ImagePixelReadAccessor<short, 2> readAccessor(im, iDi); |
| 82 | |
| 83 | itk::Index<2> idx; |
| 84 | for (int i = 0; i < xlength; ++i) |
| 85 | { |
| 86 | for (int j = 0; j < ylength; ++j) |
| 87 | { |
| 88 | idx[0] = i; |
| 89 | idx[1] = j; |
| 90 | readAccessor.GetPixelByIndexSafe(idx); |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | else |
| 95 | { |
| 96 | // use general accessor |
| 97 | mitk::ImageReadAccessor *iRA = new mitk::ImageReadAccessor(im, iDi); |
| 98 | delete iRA; |
| 99 | } |
| 100 | } |
| 101 | else |
nothing calls this directly
no test coverage detected