I am not sure that I understood what you want to do. But if I don't mistake, I think you should try to split your channels not in HSV but in HSL and work on Luminance.
#include "opencv2/opencv.hpp" int main(int ac, char **av){ cv::Mat src = cv::imread("./files/lena.jpg", -1); cv::Mat hls; // Create a hsv image with 3 channels and hue, sat e val with 1 channel. All with the same size std::vector hlsChannels; // Convert from Red-Green-Blue to Hue-Saturation-Luminance cv::cvtColor( src, hls, CV_RGB2HLS ); cv::split(hls, hlsChannels); cv::Mat hue = hlsChannels.at(0); cv::Mat lum = hlsChannels.at(1); cv::Mat sat = hlsChannels.at(2); for (int y = 0; y (y, x) += 20; } } hlsChannels.clear(); hlsChannels.push_back(hue); hlsChannels.push_back(lum); hlsChannels.push_back(sat); cv::Mat HLSColors; cv::Mat RGBColors; cv::merge(hlsChannels, HLSColors); cv::cvtColor(HLSColors, RGBColors, CV_HLS2RGB); cv::imwrite("lumLena.png", RGBColors); return 0; }
Moreover take a look to the histogram equalization it can be the first step in your work.
Hope it helped !