I want to do histogram equilization(for 16 bit image) manually without using opencv API , i am using the function :
Mat image = Mat(h, w, CV_16UC1, image_data);
Mat new_image = Mat::zeros(image.size(), image.type());
for (int x = 0; x < image.rows; ++x)
{
for (int y = 0; y < image.cols; ++y)
{
new_image.at<ushort>(x, y) = saturate_cast<ushort>(((pow(2, bpp) - 1) / (max - min))*(image.at<ushort>(x, y) - min));
}
}
Here ,
image : 16 bit image.
min : 0
max :65535
bpp :16
But i am not getting equalized image. I got half image black and half image is same as input image.
why it is happening is there need to modified the code ? Please give me any suggestion.