MCPcopy Create free account
hub / github.com/computationalpathologygroup/ASAP / run

Method run

ASAP/FilterThread.cpp:95–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95void FilterThread::run()
96{
97 forever{
98 _mutex.lock();
99 QRectF FOV = _FOV;
100 int level = _level;
101 MultiResolutionImage* img = _img;
102 int channel = _channel;
103
104 if (img) {
105 if (_abort) {
106 return;
107 }
108 if (_filterPlugin)
109 {
110 float downsample = img->getLevelDownsample(level);
111 unsigned int width = FOV.width() / downsample;
112 unsigned int height = FOV.height() / downsample;
113 Patch<double>* input = img->getPatch<double>(FOV.left(), FOV.top(), width, height, level);
114 QVariant variant;
115 if (!_restart) {
116 _filterPlugin->filter(*input, variant);
117 }
118 delete input;
119 input = NULL;
120
121 if (variant.isValid() && !variant.isNull()) {
122 Patch<double>* output = variant.value<Patch<double>*>();
123 // Image
124 if (output && !output->empty()) {
125
126 std::vector<unsigned long long> dims = output->getDimensions();
127 unsigned char* imgBuf = new unsigned char[dims[0] * dims[1] * dims[2]];
128 double *typedOutput = output->getPointer();
129
130 QImage renderedImg;
131 if (output->getColorType() == pathology::ColorType::Monochrome || output->getColorType() == pathology::ColorType::Indexed) {
132 renderedImg = convertMonochromeToRGB(typedOutput, dims[0], dims[1], 0, dims[2], output->getMinValue(), output->getMaxValue());
133 }
134 else {
135 std::copy(typedOutput, typedOutput + dims[0] * dims[1] * dims[2], imgBuf);
136 if (output->getColorType() == pathology::ColorType::RGB) {
137 renderedImg = QImage(imgBuf, dims[0], dims[1], dims[0] * dims[2], QImage::Format_RGB888);
138 }
139 else {
140 renderedImg = QImage(imgBuf, dims[0], dims[1], dims[0] * dims[2], QImage::Format_ARGB32);
141 }
142 }
143 QPixmap pixmap = QPixmap::fromImage(renderedImg);
144 QGraphicsPixmapItem* result = new QGraphicsPixmapItem(pixmap);
145 QRectF size(0, 0, width, height);
146 emit filterResult(result, size);
147 if (imgBuf) {
148 delete[] imgBuf;
149 imgBuf = NULL;
150 }
151 }
152 else {

Callers

nothing calls this directly

Calls 9

convertMonochromeToRGBFunction · 0.85
getLevelDownsampleMethod · 0.80
emptyMethod · 0.80
getPointerMethod · 0.80
getColorTypeMethod · 0.80
filterMethod · 0.45
getDimensionsMethod · 0.45
getMinValueMethod · 0.45
getMaxValueMethod · 0.45

Tested by

no test coverage detected