// JP opened flex table

Click to See Complete Forum and Search --> : image processing question


celtics
November 27th, 2003, 11:11 AM
Image Gray Scale Question
my B&W image has gray scale problem. it looks good for most part.
how to improve it?. How to (modify)Or(add to)) this header to improve gray scale?. MFC/SDI.
Celtics

LPBITMAPINFO PbmiHeader = (LPBITMAPINFO)new BYTE[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)];
PbmiHeader->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
PbmiHeader->bmiHeader.biWidth = Width;
PbmiHeader->bmiHeader.biHeight = Height;
PbmiHeader->bmiHeader.biPlanes = 1;
PbmiHeader->bmiHeader.biBitCount = 8;
PbmiHeader->bmiHeader.biCompression = 0;
PbmiHeader->bmiHeader.biSizeImage = 0;
PbmiHeader->bmiHeader.biXPelsPerMeter = 0;
PbmiHeader->bmiHeader.biYPelsPerMeter = 0;
PbmiHeader->bmiHeader.biClrUsed = 0;
PbmiHeader->bmiHeader.biClrImportant = 0;
for(int i=0; i<256; i++) {
PbmiHeader->bmiColors[i].rgbBlue = i;
PbmiHeader->bmiColors[i].rgbGreen = i;
PbmiHeader->bmiColors[i].rgbRed = i;
PbmiHeader->bmiColors[i].rgbReserved = 0;
}
HDC hdc = pDC->GetSafeHdc();
StretchDIBits( hdc, 0, 0,
Width1,
Height1,
0, 0,
Width,
Height,
data,
PbmiHeader,
DIB_RGB_COLORS,
SRCCOPY );

Marc G
November 27th, 2003, 11:38 AM
What do you mean with "improve"? Adjust contrast, brightness, gamma? Something else?

celtics
November 27th, 2003, 12:17 PM
my B&W image has gray scale problem. it looks good for most part.
needs to be smoothed uniformaly. Dark areas need to be dark uniformaly without
any fuzziness or impurities of other colors. I do not know the image processing
terms for it.(maybe gamma is the proper term for it).
How to (modify)Or(add to)) this header to improve contrast,gamma?. MFC/SDI.
Celtics

LPBITMAPINFO PbmiHeader = (LPBITMAPINFO)new BYTE[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)];
PbmiHeader->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
PbmiHeader->bmiHeader.biWidth = Width;
PbmiHeader->bmiHeader.biHeight = Height;
PbmiHeader->bmiHeader.biPlanes = 1;
PbmiHeader->bmiHeader.biBitCount = 8;
PbmiHeader->bmiHeader.biCompression = 0;
PbmiHeader->bmiHeader.biSizeImage = 0;
PbmiHeader->bmiHeader.biXPelsPerMeter = 0;
PbmiHeader->bmiHeader.biYPelsPerMeter = 0;
PbmiHeader->bmiHeader.biClrUsed = 0;
PbmiHeader->bmiHeader.biClrImportant = 0;
for(int i=0; i<256; i++) {
PbmiHeader->bmiColors[i].rgbBlue = i;
PbmiHeader->bmiColors[i].rgbGreen = i;
PbmiHeader->bmiColors[i].rgbRed = i;
PbmiHeader->bmiColors[i].rgbReserved = 0;
}
HDC hdc = pDC->GetSafeHdc();
StretchDIBits( hdc, 0, 0,
Width1,
Height1,
0, 0,
Width,
Height,
data,
PbmiHeader,
DIB_RGB_COLORS,
SRCCOPY );

Marc G
November 27th, 2003, 12:50 PM
What you want to do cannot be done by simply adding something to the header. You'll have to write your own image filter functions to apply a gaussion smooth filter and perhaps to remove noise.

For implementing image filters, take a look at http://www.codeguru.com/bitmap/index.shtml for example http://www.codeguru.com/bitmap/BlurBlendMethod.html

yiannakop
December 2nd, 2003, 07:53 AM
It looks like you need some kind of local histogram equalization. This mean that u have to work with small blocks of the image and equalize the histogram of each block.

//JP added flex table