19 #include <opencv2/core/core.hpp> 20 #include <opencv2/imgproc/imgproc.hpp> 33 int nCols = mats.front().cols;
35 std::vector<cv::Mat>::const_iterator it;
36 for (it = mats.begin(); it != mats.end(); ++it)
44 cv::Mat stacked(nRows, nCols, datatype);
45 for (it = mats.begin(); it != mats.end(); ++it)
51 CV_Assert(it->cols == nCols);
52 CV_Assert(it->type() == datatype);
55 endRow = startRow + it->rows;
56 cv::Mat mat = stacked.rowRange(startRow, endRow);
65 (*y) = coefficients[degree];
66 for (
int i = degree-1; i >= 0; i--)
69 (*y) += coefficients[i];
75 unsigned long ipa_Utils::MaskImage(
const cv::Mat& source, cv::Mat& dest,
const cv::Mat& mask, cv::Mat& destMask,
float minMaskThresh,
float maxMaskThresh,
76 int sourceChannel,
double sourceMin,
double sourceMax)
78 double globalMin = -1;
79 double globalMax = -1;
84 dest.create(source.rows, source.cols, CV_8UC3);
86 CV_Assert(sourceChannel >= 1);
87 CV_Assert(sourceChannel <= source.channels());
90 CV_Assert(destMask.depth() == CV_8U);
91 CV_Assert(destMask.channels() == 3);
92 CV_Assert(destMask.cols == source.cols);
93 CV_Assert(destMask.rows == source.rows);
96 CV_Assert(mask.depth() == CV_32F);
97 CV_Assert(mask.channels() == 1);
98 CV_Assert(mask.cols == source.cols);
99 CV_Assert(mask.rows == source.rows);
103 if (sourceMin == -1 || sourceMax == -1)
105 cv::Mat mixImage(source.rows, source.cols, source.depth(), 1);
108 int from_to[] = {sourceChannel-1, 0};
110 cv::mixChannels(&source, 1, &mixImage, 1, from_to, 1);
111 cv::minMaxLoc(mixImage, &globalMin, &globalMax);
115 std::cerr <<
"ERROR - OpenCVUtils::MaskImage:" << std::endl;
116 std::cerr <<
"\t ... Parameter sourceChannel ('" << sourceChannel <<
"') out of range.\n";
120 if (sourceMin == -1) sourceMin = globalMin;
121 if (sourceMax == -1) sourceMax = globalMax;
123 cv::minMaxLoc(mask, &maskMin, &maskMax);
124 double wMask = maskMax-maskMin;
126 double w = sourceMax-sourceMin;
131 if (source.depth() == CV_32F)
133 for(
int j=0; j<source.rows; j++)
135 const float* f_source_ptr = source.ptr<
float>(j);
136 const float* f_mask_ptr = mask.ptr<
float>(j);
138 unsigned char* c_dest_ptr = dest.ptr<
unsigned char>(j);
139 unsigned char* c_destMask_ptr = destMask.ptr<
unsigned char>(j);
141 for(
int i=0; i<source.cols; i++)
144 unsigned char vMask = 0;
146 sourceIndex = i*source.channels();
147 maskIndex = i*mask.channels();
149 double z = (double)f_source_ptr[sourceIndex + sourceChannel - 1];
150 float maskVal = f_mask_ptr[maskIndex];
151 if (maskVal < maxMaskThresh &&
152 maskVal > minMaskThresh)
157 maskVal = (float)maskMin;
162 maskVal = (float)maskMax;
164 V= (
unsigned char)(255.0 * ((z-sourceMin)/w));
166 vMask= (
unsigned char)(255.0 * ((maskVal-globalMin)/wMask));
175 c_dest_ptr[destIndex] = V;
176 c_dest_ptr[destIndex + 1] = V;
177 c_dest_ptr[destIndex + 2] = V;
179 c_destMask_ptr[destIndex] = vMask;
180 c_destMask_ptr[destIndex + 1] = vMask;
181 c_destMask_ptr[destIndex + 2] = vMask;
185 else if (source.depth() == CV_32S)
187 for(
int j=0; j<source.rows; j++)
189 const float* f_mask_ptr = mask.ptr<
float>(j);
190 const int* i_source_ptr = source.ptr<
int>(j);
191 unsigned char* c_dest_ptr = dest.ptr<
unsigned char>(j);
193 for(
int i=0; i<source.cols; i++)
198 double z = (double)i_source_ptr[i*source.channels() + sourceChannel - 1];
200 float maskVal = f_mask_ptr[maskIndex];
201 if (maskVal < maxMaskThresh &&
202 maskVal > minMaskThresh)
204 if (z < sourceMin) z = sourceMin;
205 if (z > sourceMax) z = sourceMax;
206 V = (
unsigned char)(255.0 * ((z-sourceMin)/w));
213 c_dest_ptr[iTimes3] = V;
214 c_dest_ptr[iTimes3 + 1] = V;
215 c_dest_ptr[iTimes3 + 2] = V;
219 else if (source.depth() == CV_8U)
221 for(
int j=0; j<source.rows; j++)
223 const float* f_mask_ptr = mask.ptr<
float>(j);
224 const unsigned char* c_source_ptr = source.ptr<
unsigned char>(j);
225 unsigned char* c_dest_ptr = dest.ptr<
unsigned char>(j);
227 for(
int i=0; i<source.cols; i++)
232 double z = (double)c_source_ptr[i*source.channels() + sourceChannel - 1];
234 float maskVal = f_mask_ptr[maskIndex];
235 if (maskVal < maxMaskThresh &&
236 maskVal > minMaskThresh)
238 if (z < sourceMin) z = sourceMin;
239 if (z > sourceMax) z = sourceMax;
240 V = (
unsigned char)(255.0 * ((z-sourceMin)/w));
247 c_dest_ptr[iTimes3] = V;
248 c_dest_ptr[iTimes3 + 1] = V;
249 c_dest_ptr[iTimes3 + 2] = V;
255 std::cout <<
"ERROR - OpenCVUtils::MaskImage:" << std::endl;
256 std::cout <<
"\t ... Image depth of source not supported.\n";
266 double globalMin = -1;
267 double globalMax = -1;
269 CV_Assert(channel >= 1);
270 CV_Assert(channel <= source.channels());
272 dest.create(source.rows, source.cols, CV_8UC3);
275 cv::Mat mixImage(source.rows, source.cols, source.depth(), 1);
278 int from_to[] = {channel-1, 0};
280 cv::mixChannels(&source, 1, &mixImage, 1, from_to, 1);
281 cv::minMaxLoc(mixImage, &globalMin, &globalMax);
283 if (min == -1) min = globalMin;
284 if (max == -1) max = globalMax;
288 if (source.depth() == CV_32F)
290 for(
int j=0; j<source.rows; j++)
292 const float* f_source_ptr = source.ptr<
float>(j);
293 unsigned char* c_dest_ptr = dest.ptr<
unsigned char>(j);
295 for(
int i=0; i<source.cols; i++)
299 double z = (double)f_source_ptr[i*source.channels() + channel - 1];
301 if (z < min) z = min;
302 if (z > max) z = max;
304 int V= (int)(255.0 * ((z-min)/w));
306 c_dest_ptr[iTimes3] = V;
307 c_dest_ptr[iTimes3 + 1] = V;
308 c_dest_ptr[iTimes3 + 2] = V;
312 else if (source.depth() == CV_32S)
314 for(
int j=0; j<source.rows; j++)
316 const int* i_source_ptr = source.ptr<
int>(j);
317 unsigned char* c_dest_ptr = dest.ptr<
unsigned char>(j);
319 for(
int i=0; i<source.cols; i++)
323 double z = (double)i_source_ptr[i*source.channels() + (channel - 1)];
325 if (z < min) z = min;
326 if (z > max) z = max;
328 int V= (int)(255.0 * ((z-min)/w));
330 c_dest_ptr[iTimes3] = V;
331 c_dest_ptr[iTimes3 + 1] = V;
332 c_dest_ptr[iTimes3 + 2] = V;
336 else if (source.depth() == CV_8U)
338 for(
int j=0; j<source.rows; j++)
340 const unsigned char* c_source_ptr = source.ptr<
unsigned char>(j);
341 unsigned char* c_dest_ptr = dest.ptr<
unsigned char>(j);
343 for(
int i=0; i<source.cols; i++)
347 double z = (double)c_source_ptr[i*source.channels() + (channel - 1)];
349 if (z < min) z = min;
350 if (z > max) z = max;
352 int V= (int)(255.0 * ((z-min)/w));
354 c_dest_ptr[iTimes3] = V;
355 c_dest_ptr[iTimes3 + 1] = V;
356 c_dest_ptr[iTimes3 + 2] = V;
360 else if (source.depth() == CV_16U)
362 for(
int j=0; j<source.rows; j++)
364 const unsigned short* c_source_ptr = source.ptr<
unsigned short>(j);
365 unsigned char* c_dest_ptr = dest.ptr<
unsigned char>(j);
367 for(
int i=0; i<source.cols; i++)
371 double z = (double)c_source_ptr[i*source.channels() + (channel - 1)];
373 if (z < min) z = min;
374 if (z > max) z = max;
376 int V= (int)(255.0 * ((z-min)/w));
378 c_dest_ptr[iTimes3] = V;
379 c_dest_ptr[iTimes3 + 1] = V;
380 c_dest_ptr[iTimes3 + 2] = V;
386 std::cout <<
"ERROR - OpenCVUtils::ConvertToShowImage:" << std::endl;
387 std::cout <<
"\t ... Image depth of source not supported.\n";
395 unsigned long ipa_Utils::FilterByAmplitude(cv::Mat& xyzImage,
const cv::Mat& greyImage, cv::Mat* mask, cv::Mat* maskColor,
float minMaskThresh,
float maxMaskThresh)
397 CV_Assert(xyzImage.type() == CV_32FC3);
398 CV_Assert(greyImage.type() == CV_32FC1);
400 if(mask) mask->create(greyImage.size(), CV_32FC1);
401 if(maskColor) maskColor->create(greyImage.size(), CV_8UC3);
404 int maskColorIndex = 0;
408 unsigned char* c_maskColor_ptr = 0;
409 float* f_xyz_ptr = 0;
410 const float* f_grey_ptr = 0;
411 float* f_mask_ptr = 0;
413 for(
int j=0; j<xyzImage.rows; j++)
415 f_xyz_ptr = xyzImage.ptr<
float>(j);
416 f_grey_ptr = greyImage.ptr<
float>(j);
417 if(mask) f_mask_ptr = mask->ptr<
float>(j);
418 if(maskColor) c_maskColor_ptr = maskColor->ptr<
unsigned char>(j);
420 for(
int i=0; i<xyzImage.cols; i++)
424 maskColorIndex = i*3;
426 double z = (double)f_xyz_ptr[xyzIndex + 2];
427 float maskVal = f_grey_ptr[i];
432 if(maskVal>maxMaskThresh)
434 c_maskColor_ptr[maskColorIndex]= 0;
435 c_maskColor_ptr[maskColorIndex+1]= 0;
436 c_maskColor_ptr[maskColorIndex+2]= 255;
438 else if(maskVal<minMaskThresh)
440 c_maskColor_ptr[maskColorIndex]= 0;
441 c_maskColor_ptr[maskColorIndex+1]= 255;
442 c_maskColor_ptr[maskColorIndex+2]= 0;
446 c_maskColor_ptr[maskColorIndex]= 255;
447 c_maskColor_ptr[maskColorIndex+1]= 0;
448 c_maskColor_ptr[maskColorIndex+2]= 0;
452 c_maskColor_ptr[maskColorIndex]= 0;
453 c_maskColor_ptr[maskColorIndex+1]= 0;
454 c_maskColor_ptr[maskColorIndex+2]= 0;
458 if (maskVal < maxMaskThresh &&
459 maskVal > minMaskThresh)
466 f_xyz_ptr[xyzIndex] = V;
467 f_xyz_ptr[xyzIndex + 1] = V;
468 f_xyz_ptr[xyzIndex + 2] = V;
473 f_mask_ptr[i] = vMask;
485 CV_Assert(xyzImage.type() == CV_32FC3);
488 float t_lower =pi/piHalfFraction;
489 float t_upper = pi - t_lower;
493 mask->create(xyzImage.size() , CV_8UC3);
497 for(
int row=0; row < xyzImage.rows; row++)
499 int index_vLeft = -1;
500 int index_vMiddle = -1;
501 int index_vRight = -1;
503 int index_vDown = -1;
505 cv::Vec3f vLeft = cv::Vec3f::all(0);
506 cv::Vec3f vMiddle = cv::Vec3f::all(0);
507 cv::Vec3f vRight = cv::Vec3f::all(0);
508 cv::Vec3f vUp = cv::Vec3f::all(0);
509 cv::Vec3f vDown = cv::Vec3f::all(0);
511 cv::Vec3f vDiff = cv::Vec3f::all(0);
513 float* f_image_ptr_RowUp = 0;
514 float* f_image_ptr_RowMiddle = 0;
515 float* f_image_ptr_RowDown = 0;
522 f_image_ptr_RowUp = xyzImage.ptr<
float>(row-1);
525 f_image_ptr_RowMiddle = xyzImage.ptr<
float>(row);
527 if (row+1 < xyzImage.rows)
529 f_image_ptr_RowDown = xyzImage.ptr<
float>(row+1);
538 for(
int col=0; col < xyzImage.cols; col++)
545 vMiddle[0] = f_image_ptr_RowMiddle[3*index_vMiddle];
546 vMiddle[1] = f_image_ptr_RowMiddle[3*index_vMiddle + 1];
547 vMiddle[2] = f_image_ptr_RowMiddle[3*index_vMiddle + 2];
553 vLeft[0] = f_image_ptr_RowMiddle[3*index_vLeft];
554 vLeft[1] = f_image_ptr_RowMiddle[3*index_vLeft + 1];
555 vLeft[2] = f_image_ptr_RowMiddle[3*index_vLeft + 2];
556 vDiff = vLeft - vMiddle;
557 float vLeftNorm = std::sqrt((vLeft[0] * vLeft[0]) +
558 (vLeft[1] * vLeft[1]) + (vLeft[2] * vLeft[2]));
559 vLeft[0] = vLeft[0]/vLeftNorm;
560 vLeft[1] = vLeft[1]/vLeftNorm;
561 vLeft[2] = vLeft[2]/vLeftNorm;
563 float vDiffNorm = std::sqrt((vDiff[0] * vDiff[0]) +
564 (vDiff[1] * vDiff[1]) + (vDiff[2] * vDiff[2]));
565 vDiff[0] = vDiff[0]/vDiffNorm;
566 vDiff[1] = vDiff[1]/vDiffNorm;
567 vDiff[2] = vDiff[2]/vDiffNorm;
569 dot = (float)vDiff.ddot(vLeft);
571 angle = (float)std::acos(dot);
573 if (angle > t_upper || angle < t_lower)
584 if (col+1 < xyzImage.rows)
586 index_vRight = col+1;
587 vRight[0] = f_image_ptr_RowMiddle[3*index_vRight];
588 vRight[1] = f_image_ptr_RowMiddle[3*index_vRight + 1];
589 vRight[2] = f_image_ptr_RowMiddle[3*index_vRight + 2];
590 vDiff = vRight - vMiddle;
591 float vRightNorm = std::sqrt((vRight[0] * vRight[0]) +
592 (vRight[1] * vRight[1]) + (vRight[2] * vRight[2]));
593 vRight[0] = vRight[0]/vRightNorm;
594 vRight[1] = vRight[1]/vRightNorm;
595 vRight[2] = vRight[2]/vRightNorm;
597 float vDiffNorm = std::sqrt((vDiff[0] * vDiff[0]) +
598 (vDiff[1] * vDiff[1]) + (vDiff[2] * vDiff[2]));
599 vDiff[0] = vDiff[0]/vDiffNorm;
600 vDiff[1] = vDiff[1]/vDiffNorm;
601 vDiff[2] = vDiff[2]/vDiffNorm;
603 dot = (float)vDiff.ddot(vLeft);
605 angle = (float)std::acos(dot);
607 if (angle > t_upper || angle < t_lower)
618 if (f_image_ptr_RowUp)
621 vUp[0] = f_image_ptr_RowUp[3*index_vUp];
622 vUp[1] = f_image_ptr_RowUp[3*index_vUp + 1];
623 vUp[2] = f_image_ptr_RowUp[3*index_vUp + 2];
624 vDiff = vUp - vMiddle;
625 float vUpNorm = std::sqrt((vUp[0] * vUp[0]) +
626 (vUp[1] * vUp[1]) + (vUp[2] * vUp[2]));
627 vUp[0] = vUp[0]/vUpNorm;
628 vUp[1] = vUp[1]/vUpNorm;
629 vUp[2] = vUp[2]/vUpNorm;
631 float vDiffNorm = std::sqrt((vDiff[0] * vDiff[0]) +
632 (vDiff[1] * vDiff[1]) + (vDiff[2] * vDiff[2]));
633 vDiff[0] = vDiff[0]/vDiffNorm;
634 vDiff[1] = vDiff[1]/vDiffNorm;
635 vDiff[2] = vDiff[2]/vDiffNorm;
637 dot = (float)vDiff.ddot(vLeft);
639 angle = (float)std::acos(dot);
641 if (angle > t_upper || angle < t_lower)
652 if (f_image_ptr_RowDown)
655 vDown[0] = f_image_ptr_RowDown[3*index_vDown];
656 vDown[1] = f_image_ptr_RowDown[3*index_vDown + 1];
657 vDown[2] = f_image_ptr_RowDown[3*index_vDown + 2];
658 float vDownNorm = std::sqrt((vDown[0] * vDown[0]) +
659 (vDown[1] * vDown[1]) + (vDown[2] * vDown[2]));
660 vDown[0] = vDown[0]/vDownNorm;
661 vDown[1] = vDown[1]/vDownNorm;
662 vDown[2] = vDown[2]/vDownNorm;
664 float vDiffNorm = std::sqrt((vDiff[0] * vDiff[0]) +
665 (vDiff[1] * vDiff[1]) + (vDiff[2] * vDiff[2]));
666 vDiff[0] = vDiff[0]/vDiffNorm;
667 vDiff[1] = vDiff[1]/vDiffNorm;
668 vDiff[2] = vDiff[2]/vDiffNorm;
670 dot = (float)vDiff.ddot(vLeft);
672 angle = (float)std::acos(dot);
674 if (angle > t_upper || angle < t_lower)
688 cv::Vec3b pt(0, 0, 0);
691 mask->at<cv::Vec3b>(row,col)=pt;
694 for(
int i = 0; i < 3; i++)
695 ((
float*)xyzImage.ptr(row))[3*col+i] = 0.
f;
704 double maxDiff, cv::Mat& _buf)
706 CV_Assert( img.type() == CV_32FC3 );
709 int width = img.cols, height = img.rows, npixels = width*height;
710 size_t bufSize = npixels*(int)(
sizeof(cv::Point_<short>) +
sizeof(int) +
sizeof(uchar));
711 if( !_buf.isContinuous() || !_buf.data || _buf.cols*_buf.rows*_buf.elemSize() < bufSize )
712 _buf.create(1, bufSize, CV_8U);
714 uchar* buf = _buf.data;
715 int i, j, dstep = img.step/
sizeof(cv::Vec3f);
716 int* labels = (
int*)buf;
717 buf += npixels*
sizeof(labels[0]);
718 cv::Point_<short>* wbuf = (cv::Point_<short>*)buf;
719 buf += npixels*
sizeof(wbuf[0]);
720 uchar* rtype = (uchar*)buf;
724 memset(labels, 0, npixels*
sizeof(labels[0]));
726 for( i = 0; i < height; i++ )
728 cv::Vec3f* ds = img.ptr<cv::Vec3f>(i);
729 int* ls = labels + width*i;
731 for( j = 0; j < width; j++ )
733 if( ds[j][2] != newVal )
739 ds[j][0] = (float)newVal;
740 ds[j][1] = (float)newVal;
741 ds[j][2] = (float)newVal;
747 cv::Point_<short>* ws = wbuf;
748 cv::Point_<short> p((
short)j, (
short)i);
758 cv::Vec3f* dpp = &img.at<cv::Vec3f>(p.y, p.x);
760 int* lpp = labels + width*p.y + p.x;
762 if( p.x < width-1 && !lpp[+1] && dpp[+1][2] != newVal && std::abs(dp[2] - dpp[+1][2]) <= maxDiff )
765 *ws++ = cv::Point_<short>(p.x+1, p.y);
768 if( p.x > 0 && !lpp[-1] && dpp[-1][2] != newVal && std::abs(dp[2] - dpp[-1][2]) <= maxDiff )
771 *ws++ = cv::Point_<short>(p.x-1, p.y);
774 if( p.y < height-1 && !lpp[+width] && dpp[+dstep][2] != newVal && std::abs(dp[2] - dpp[+dstep][2]) <= maxDiff )
776 lpp[+width] = curlabel;
777 *ws++ = cv::Point_<short>(p.x, p.y+1);
780 if( p.y > 0 && !lpp[-width] && dpp[-dstep][2] != newVal && std::abs(dp[2] - dpp[-dstep][2]) <= maxDiff )
782 lpp[-width] = curlabel;
783 *ws++ = cv::Point_<short>(p.x, p.y-1);
792 if( count <= maxSpeckleSize )
795 ds[j][0] = (float)newVal;
796 ds[j][1] = (float)newVal;
797 ds[j][2] = (float)newVal;
813 rgb[0]=rgb[1]=rgb[2]=(
unsigned char)(255*value/max);
814 return cv::Vec3b(rgb[2], rgb[1], rgb[0]);
821 std::ofstream
f(filename.c_str(), std::ios_base::binary);
824 std::cerr <<
"ERROR - ipa_Utils::SaveMat:" << std::endl;
825 std::cerr <<
"\t ... Could not open " << filename <<
" \n";
829 int channels = mat.channels();
832 header[0] = mat.rows;
833 header[1] = mat.cols;
834 header[2] = channels;
837 f.write((
char*)header, 3 *
sizeof(
int));
839 f.write((
char const*)header, 3 *
sizeof(
int));
845 for(
unsigned int row=0; row<(
unsigned int)mat.rows; row++)
847 ptr = mat.ptr<
float>(row);
848 f.write((
char*)ptr, channels * mat.cols *
sizeof(
float));
853 unsigned char* ptr = 0;
854 for(
unsigned int row=0; row<(
unsigned int)mat.rows; row++)
856 ptr = mat.ptr<
unsigned char>(row);
857 f.write((
char*)ptr, channels * mat.cols *
sizeof(
unsigned char));
867 size_t file_length = 0;
870 std::ifstream file(filename.c_str(), std::ios_base::binary|std::ios_base::in|std::ios_base::ate);
873 std::cerr <<
"ERROR - ipa_Utils::LoadMat:" << std::endl;
874 std::cerr <<
"\t ... Could not open " << filename <<
" \n";
878 file_length = file.tellg();
879 file.seekg(0, std::ios_base::beg);
882 c_string =
new char[file_length];
883 file.read(c_string, file_length);
885 unsigned int rows, cols;
887 rows = ((
int*)c_string)[0];
888 cols = ((
int*)c_string)[1];
889 channels = ((
int*)c_string)[2];
896 mat.create(rows, cols, CV_32FC(channels));
897 f_ptr = mat.ptr<
float>(0);
898 c_ptr = &c_string[3 *
sizeof(int)];
900 memcpy(f_ptr, c_ptr, channels * mat.cols * mat.rows *
sizeof(
float));
904 unsigned char* f_ptr;
905 mat.create(rows, cols, CV_32FC(channels));
906 f_ptr = mat.ptr<
unsigned char>(0);
907 c_ptr = &c_string[3 *
sizeof(int)];
909 memcpy(f_ptr, c_ptr, channels * mat.cols * mat.rows *
sizeof(
unsigned char));
cv::Mat vstack(const std::vector< cv::Mat > &mats)
unsigned long ConvertToShowImage(const cv::Mat &source, cv::Mat &dest, int channel=1, double min=-1, double max=-1)
unsigned long SaveMat(cv::Mat &mat, std::string filename, int type=CV_32F)
unsigned long FilterSpeckles(cv::Mat &img, int maxSpeckleSize, double _maxDiff, cv::Mat &_buf)
Description.
cv::Vec3b GrayColorMap(double value, double min, double max)
std_msgs::Header * header(M &m)
unsigned long LoadMat(cv::Mat &mat, std::string filename, int type=CV_32F)
unsigned long MaskImage(const cv::Mat &source, cv::Mat &dest, const cv::Mat &mask, cv::Mat &destMask, float minMaskThresh=0, float maxMaskTresh=20000, int sourceChannel=1, double sourceMin=-1, double sourceMax=-1)
unsigned long EvaluatePolynomial(double x, int degree, double *coefficients, double *y)
unsigned long FilterTearOffEdges(cv::Mat &xyzImage, cv::Mat *mask, float piHalfFraction=6)
unsigned long FilterByAmplitude(cv::Mat &xyzImage, const cv::Mat &greyImage, cv::Mat *mask, cv::Mat *maskColor, float minMaskThresh, float maxMaskThresh)
Something went dramatically wrong.