Does clahe work on 16uc1 image?I tried myself but got unexpected result.Plz suggest me the way that we can use the Clahe on 16bit(3channel/1channel) image..Thanx
I used mat in opencv cpp code to load images
Here is my code:
cv::Mat srcImage_3channels = cv::imread(InputPath, CV_LOAD_IMAGE_UNCHANGED);
cv::Mat srcImage = cv::Mat::zeros(srcImage_3channels.rows, srcImage_3channels.cols, CV_16UC1);
UINT16* src_3 = (UINT16*)srcImage_3channels.data;
UINT16* src = (UINT16*)srcImage.data;
int B = 0;
for (int j = 0; j < srcImage_3channels.rows; j++)
{
for (int i = 0; i < srcImage_3channels.cols; i ++)
{
B = src_3[i*3 + j*srcImage_3channels.cols * 3];
src[(i)+j*srcImage.cols] = (UINT16)B;//getting single channel from 3 channel image
}
}
test::cvClahe(srcImage, srcImage, clipLimit);
cv::imwrite(OutputPath, srcImage);
what is the problem, exaactly ?
I am seeing random and strange intensities in the output..they look like over saturated and under saturated.. I stretched this 16 bit input img to 8 bit ,then applied the clahe on this 8 bit..i got the expected result..(this is for verification)
I verified all imgs loadings ,savings and intensities using pixel access..all are gone well
btw, CLAHE only works on a single channel, and applying it to bgr images does not make any sense.
@berak. srcImage is single channel image..plz see its declaration
also, please NEVER write loops like above.
use split() or extractCOI() to get a single channel.
Thanks for feedback.
cv::Mat srcImage_3channels = cv::imread(InputPath, CV_LOAD_IMAGE_UNCHANGED);
Tried as u suggest ,but got same result as earlier one
Found that ..clahe algo is expecting max value of 4096 instead of (2 power of 16=65535).. Max value in my input =65535 So i stretched the input image from 65535 to 4096..Got good result instead of over saturated pixels..but didnt see contrast enhancement in output..need to work on it.. used web link github
ah, makes sense.
it's probably 4096, because it was optimized for depth data.