Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
  1. YES ;)
  2. cv::typeToString()
  3. no idea, sorry .
  4. convertTo() changes the Mat's depth, e.g. from float to uchar, NOT the channels or the colorspace, that's what cvtColor() is for.
  5. please DON'T write loops for this. there will always be a builtin function, that does the job faster, less error prone , etc. (you probably would have neded a saturate_cast<uchar>() to avoid the overflow).


long story short, it needs 2 steps:

Mat hdr(FreeImage_GetHeight(hdrImage), FreeImage_GetWidth(hdrImage), CV_32FC4, FreeImage_GetBits(hdrImage), FreeImage_GetPitch(hdrImage));

Mat bgr;
hdr.convertTo(bgr, CV_8U, 255);
Mat gray;
cvtColor(bgr,gray,COLOR_BGRA2GRAY);
  1. YES ;)
  2. cv::typeToString()
  3. there is a cuda gamma corrrection, but afaik, no idea, sorry .cpu version
  4. convertTo() changes the Mat's depth, e.g. from float to uchar, NOT the channels or the colorspace, that's what cvtColor() is for.
  5. please DON'T write loops for this. there will always be a builtin function, that does the job faster, less error prone , etc. (you probably would have neded a saturate_cast<uchar>() to avoid the overflow).


long story short, it needs 2 steps:

Mat hdr(FreeImage_GetHeight(hdrImage), FreeImage_GetWidth(hdrImage), CV_32FC4, FreeImage_GetBits(hdrImage), FreeImage_GetPitch(hdrImage));

Mat bgr;
hdr.convertTo(bgr, CV_8U, 255);
Mat gray;
cvtColor(bgr,gray,COLOR_BGRA2GRAY);
  1. YES ;)
  2. cv::typeToString()
  3. there is a cuda gamma corrrection, but afaik, no cpu version
  4. convertTo() changes the Mat's depth, e.g. from float to uchar, NOT the channels or the colorspace, that's what cvtColor() is for.
  5. please DON'T write loops for this. there will always be a builtin function, that does the job faster, less error prone , etc. (you probably would have neded a saturate_cast<uchar>() to avoid the overflow).


long story short, it needs 2 steps:steps to go from CV_32FC4 to CV_8U:

Mat hdr(FreeImage_GetHeight(hdrImage), FreeImage_GetWidth(hdrImage), CV_32FC4, FreeImage_GetBits(hdrImage), FreeImage_GetPitch(hdrImage));

Mat bgr;
hdr.convertTo(bgr, CV_8U, 255);
Mat gray;
cvtColor(bgr,gray,COLOR_BGRA2GRAY);