mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 06:03:15 +08:00
fixing confusing variable naming in a sample code
This commit is contained in:
parent
f01b2413c3
commit
eeae81e903
@ -154,13 +154,14 @@ It is possible to store PNG images with an alpha channel using this function. To
|
|||||||
|
|
||||||
void createAlphaMat(Mat &mat)
|
void createAlphaMat(Mat &mat)
|
||||||
{
|
{
|
||||||
|
CV_Assert(mat.channels() == 4);
|
||||||
for (int i = 0; i < mat.rows; ++i) {
|
for (int i = 0; i < mat.rows; ++i) {
|
||||||
for (int j = 0; j < mat.cols; ++j) {
|
for (int j = 0; j < mat.cols; ++j) {
|
||||||
Vec4b& rgba = mat.at<Vec4b>(i, j);
|
Vec4b& bgra = mat.at<Vec4b>(i, j);
|
||||||
rgba[0] = UCHAR_MAX;
|
bgra[0] = UCHAR_MAX; // Blue
|
||||||
rgba[1] = saturate_cast<uchar>((float (mat.cols - j)) / ((float)mat.cols) * UCHAR_MAX);
|
bgra[1] = saturate_cast<uchar>((float (mat.cols - j)) / ((float)mat.cols) * UCHAR_MAX); // Green
|
||||||
rgba[2] = saturate_cast<uchar>((float (mat.rows - i)) / ((float)mat.rows) * UCHAR_MAX);
|
bgra[2] = saturate_cast<uchar>((float (mat.rows - i)) / ((float)mat.rows) * UCHAR_MAX); // Red
|
||||||
rgba[3] = saturate_cast<uchar>(0.5 * (rgba[1] + rgba[2]));
|
bgra[3] = saturate_cast<uchar>(0.5 * (bgra[1] + bgra[2])); // Alpha
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user