1 | initial version |
convertTo()
changes the Mat's depth, e.g. from float to uchar, NOT the channels or the colorspace, that's what cvtColor()
is for.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);
2 | No.2 Revision |
convertTo()
changes the Mat's depth, e.g. from float to uchar, NOT the channels or the colorspace, that's what cvtColor()
is for.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);
3 | No.3 Revision |
convertTo()
changes the Mat's depth, e.g. from float to uchar, NOT the channels or the colorspace, that's what cvtColor()
is for.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);