i have found this formula and its description on a site
l(x,y)=(l(x,y)-min)(no of intensity levels/(max-min)) + initial intensity level
where, I( x,y ) represents the images, on the left side it represents the output image, while on the right side it represents the xth pixel in the yth column in the input image. In this equation the "min" and "max" are the minimum intensity value and the minimum intensity value in the current image. Here "no. of intensity levels" shows the total number of intensity values that can be assigned to a pixel. For example, normally in the gray-level images, the lowest possible intensity is 0, and the highest intensity value is 255. Thus "no. of intensity levels" is equal to 255.
i have converted it into code, have i correctly converted it?
for(int y = 0; y < bmp.bmHeight; y++)
{
for(int x = 0; x < bmp.bmWidth; x++)
{
COLORREF rgb = dc.GetPixel(x, y);
BYTE r = GetRValue(rgb);
BYTE g = GetGValue(rgb);
BYTE b = GetBValue(rgb);
BYTE p,p1;
if(r<g)
{
p=r;
p1=g;
}
else
{
p=g;
p1=r;
}
if(b<p)
p=b;
if(b>p1)
p1=b;
BYTE bw = (RGB(r, g, b)-p);
bw=bw*(255/(p1-p));
bw+=p1;
dc.SetPixel(x, y, RGB(bw, bw, bw));
}