1 | initial version |
no, you don't have to do that "per-pixel". it's just 2 easy steps:
// 1. make a 3-channel grayscale image with half the original intensity:
Mat gray_half;
cvtColor(gray * 0,5, gray_half, CV_GRAY2BGR);
// 2. subtract that from original:
Mat result = img - gray_half;
2 | No.2 Revision |
no, you don't have to do that "per-pixel". it's just 2 easy steps:
// 0. that's what you already got:
Mat img = ... // bgr image from somewhere
Mat gray;
cvtColor(img, gray, CV_BGR2GRAY);
// 1. make a 3-channel grayscale image with half the original intensity:
// (to subtract later, we need images with equal channel count, so just duplicate gray 3 times)
Mat gray_half;
cvtColor(gray * 0,5, gray_half, CV_GRAY2BGR);
// 2. subtract that from original:
Mat result = img - gray_half;