Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cvtColor hls to rgb lightening image

HI,

I am trying to lighten an image by converting to HLS and then adjusting the lightness channel

cv::Mat hls;
cv::Mat planes[3];

cv::cvtColor(frame, hls, cv::ColorConversionCodes::COLOR_BGR2HLS);

cv::split(hls, planes);

planes[1] += 50;

cv::merge(planes, 3, hls);

// make BGR image to display
cv::cvtColor(hls, frame, cv::ColorConversionCodes::COLOR_HLS2BGR);

The problem is though that, after it has been lightened by the planes[1] += 50; call, the image has had it's colours changed and the darker pixels in the image now appear green, the other pixels do seem to be lightened though (the original image was a dark monotone image).

Any idea why this is happening and how I can get round this problem, I think it must be something to do with the Chroma component of the HLS-RGB conversion scheme?

Cheers

Dave

cvtColor hls to rgb lightening image

HI,

I am trying to lighten an image by converting to HLS and then adjusting the lightness channel

cv::Mat hls;
cv::Mat planes[3];

cv::cvtColor(frame, hls, cv::ColorConversionCodes::COLOR_BGR2HLS);

cv::split(hls, planes);

planes[1] += 50;

cv::merge(planes, 3, hls);

// make BGR image to display
cv::cvtColor(hls, frame, cv::ColorConversionCodes::COLOR_HLS2BGR);

The problem is though that, after it has been lightened by the planes[1] += 50; call, the image has had it's colours changed and the darker pixels in the image now appear green, the other pixels do seem to be lightened though (the original image was a dark monotone image).

Any idea why this is happening and how I can get round this problem, I think it must be something to do with the Chroma component of the HLS-RGB conversion scheme?

Cheers

Dave

C:\fakepath\plotsm.png

cvtColor hls to rgb lightening image

HI,

I am trying to lighten an image by converting to HLS and then adjusting the lightness channel

cv::Mat hls;
cv::Mat planes[3];

cv::cvtColor(frame, hls, cv::ColorConversionCodes::COLOR_BGR2HLS);

cv::split(hls, planes);

planes[1] += 50;

cv::merge(planes, 3, hls);

// make BGR image to display
cv::cvtColor(hls, frame, cv::ColorConversionCodes::COLOR_HLS2BGR);

The problem is though that, after it has been lightened by the planes[1] += 50; call, the image has had it's colours changed and the darker pixels in the image now appear green, the other pixels do seem to be lightened though (the original image was a dark monotone image).

Any idea why this is happening and how I can get round this problem, I think it must be something to do with the Chroma component of the HLS-RGB conversion scheme?

Cheers

Dave

C:\fakepath\plotsm.png

cvtColor hls to rgb lightening image

HI,

I am trying to lighten an image by converting to HLS and then adjusting the lightness channel

cv::Mat hls;
cv::Mat planes[3];

cv::cvtColor(frame, hls, cv::ColorConversionCodes::COLOR_BGR2HLS);

cv::split(hls, planes);

planes[1] += 50;

cv::merge(planes, 3, hls);

// make BGR image to display
cv::cvtColor(hls, frame, cv::ColorConversionCodes::COLOR_HLS2BGR);

The problem is though that, after it has been lightened by the planes[1] += 50; call, the image has had it's colours changed and the darker pixels in the image now appear green, the other pixels do seem to be lightened though (the original image was a dark monotone image).

Any idea why this is happening and how I can get round this problem, I think it must be something to do with the Chroma component of the HLS-RGB conversion scheme?

Cheers

Dave

C:\fakepath\plotsm.png

cvtColor hls to rgb lightening image

HI,

I am trying to lighten an image by converting to HLS and then adjusting the lightness channel

cv::Mat hls;
cv::Mat planes[3];

cv::cvtColor(frame, hls, cv::ColorConversionCodes::COLOR_BGR2HLS);

cv::split(hls, planes);

planes[1] += 50;

cv::merge(planes, 3, hls);

// make BGR image to display
cv::cvtColor(hls, frame, cv::ColorConversionCodes::COLOR_HLS2BGR);

The problem is though that, after it has been lightened by the planes[1] += 50; call, the image has had it's colours changed and the darker pixels in the image now appear green, the other pixels do seem to be lightened though (the original image was a dark monotone image).

Any idea why this is happening and how I can get round this problem, I think it must be something to do with the Chroma component of the HLS-RGB conversion scheme?

Cheers

Dave

C:\fakepath\plotsm.pngC:\fakepath\plotsm.png

cvtColor hls to rgb lightening image

HI,

I am trying to lighten an image by converting to HLS and then adjusting the lightness channel

cv::Mat hls;
cv::Mat planes[3];

cv::cvtColor(frame, hls, cv::ColorConversionCodes::COLOR_BGR2HLS);

cv::split(hls, planes);

   cv::Mat intensity = planes[1];

   blur(intensity, intensity, cv::Size(100, 100));

   planes[1] += 50;
= intensity;

cv::merge(planes, 3, hls);

// make BGR image to display
cv::cvtColor(hls, frame, cv::ColorConversionCodes::COLOR_HLS2BGR);

The problem is though that, after it has been lightened by the planes[1] += 50; call, the image has had it's colours changed and the darker pixels in the image now appear green, the other pixels do seem to be lightened though (the original image was a dark monotone image).

Any idea why this is happening and how I can get round this problem, I think it must be something to do with the Chroma component of the HLS-RGB conversion scheme?

Cheers

Dave

C:\fakepath\plotsm.png

cvtColor hls to rgb lightening image

HI,

I am trying to lighten an image by converting to HLS and then adjusting the lightness channel

cv::Mat hls;
cv::Mat planes[3];

cv::cvtColor(frame, hls, cv::ColorConversionCodes::COLOR_BGR2HLS);

cv::split(hls, planes);

   cv::Mat intensity = planes[1];

   blur(intensity, intensity, cv::Size(100, 100));

   // make sure lightness is within 0->1 bounds
intensity.forEach<float>([&](float& pixel, const int po[]) -> void {
    pixel = fmin(1.0, fmax(0.0, pixel));
}
);

   planes[1] = intensity;

cv::merge(planes, 3, hls);

// make BGR image to display
cv::cvtColor(hls, frame, cv::ColorConversionCodes::COLOR_HLS2BGR);

The problem is though that, after it has been lightened by the planes[1] += 50; call, the image has had it's colours changed and the darker pixels in the image now appear green, the other pixels do seem to be lightened though (the original image was a dark monotone image).

Any idea why this is happening and how I can get round this problem, I think it must be something to do with the Chroma component of the HLS-RGB conversion scheme?

Cheers

Dave

C:\fakepath\plotsm.png