- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Hello All,

I just implemented the histogram equalization technique using intel ipp functions. Since Histogram equalization equalizes within the two extreem values, I was thinking of implementing other methods for auto contrast.

Is there any way that I can perform auto contrast and not histogram equlaiztion?

Thanks,

Sharath

Link Copied

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

I'm also interested in discussing automatic contrast algorithms.

Histogram Equalization, Histogram Stretching, Gamma Correction etc.

The problem is, you start with a bad grayscale image, and how do you present it perfectly, automatically?

The bad image is full of problems: under/over exposed, artifacts etc.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

**auto contrast**and not histogram equlaiztion? I would try to do it using a simple algorithm to calculate Center of Gravity of a Histogram represented as a small image. I know that in Point-and-Shot digital cameras and webcams it is done in a very simple way. Which one? I do not know.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Center of gravity is an area (with a fixed width) in the histogram, where the Percentile is highest.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

I learnt that "Center of Gravity" of a histogram is the mean of the histogram values. I am not knowing if "mean" would be a good factor in performing the auto contrast. Any thoughts on this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

**histogram**of some Source Image ( SI ) as

**an Histogram Image**( HI ), for example, with dimensions 128x128 pixels ( _int8 data type ). Now, 3 cases are possible and

**If**: - The histogram is "shifted" to the left part of the HI than the SI is underexposed - The "summit" of the histogram is in the "middle" of the HI than the SI is properly exposed - The histogram is "shifted" to the right part of the HI than the SI is overexposed A simple calculation of the

**Center of Gravity**for HI could tell you how you should adjust parameters of a camera in order to take a properly exposed image. The same rules could be applied for Auto-Contrast processing.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Thanks Sergey for that quick response. It totally makes sense to take the center of gravity now. I will try it out and let you know about it.

I was also curious to know if there are any IPP functions to calcualte the "Center of Gravity". If yes, kindly let me know.

Thanks,

Sharath

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

**CalcCenterOfGravityF**( RTfloat *pfMatrix, RTint iR, RTint iC, RTint *piCoGX, RTint *piCoGY ); RTvoid

**CalcCenterOfGravityF**( RTfloat *pfMatrix, RTint iR, RTint iC, RTint *piCoGX, RTint *piCoGY ) { RTfloat fCoGX = 0.0f; RTfloat fCoGY = 0.0f; RTfloat fTotalI = 0.0f; RTfloat fPxValue = 0.0f; for( RTint r = 0; r < iR; r++ ) { RTint iRTemp = ( r * iC ); for( RTint c = 0; c < iC; c++ ) { fPxValue = *( pfMatrix + ( iRTemp + c ) ); fCoGX += ( fPxValue * c ); fCoGY += ( fPxValue * r ); fTotalI += fPxValue; } } if( fTotalI != 0.0f ) { *piCoGX = ( RTint )( fCoGX / fTotalI ); *piCoGY = ( RTint )( fCoGY / fTotalI ); } else { *piCoGX = 0; *piCoGY = 0; } } Please do all the rest clean ups. Note: a template-based implementation of the function is more flexible.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Sergey, Thanks for posting the code snippet with your test cases. Since I am fairly new to image processing, It took me sometime to understand your code. It would be more helpful if you had comments to walk me through. Nevertheless It is very helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Sergey, I have lots of grayscale images that just cannot be displayed "perfectly" automatically,

The problem is always that the histogram of the grayscale image has large parts that must be avoided before doing automatic this-and-that.

I call those part artifacts. One artifact can be a wide tall peak in the white part, or a narrow high peak in the medium gray part. Those must be removed before applying autmatic algorithms. One way of "removing" is to mask the image before the histogra is computed, another way is to patch the histogram, supressing an easy to detect artifact.

I already use "stretching", wherein I move zero or very low black point and zero or very low white point, using percentiles to determine when to stop. To find the grayscale of greatest interest, I use what I described above, sliding a wide band over the histogram, choosing the location having the higest percentile.

Suggestions are welcome.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

**Note:**I wonder if you use a classic one widelly used in Machine Vision applications for greyscale ( monochrome ) images: %Contrast = ( Imax - Imin ) / MaxValueOfDynamicRange For example, for 8-bit images MaxValueOfDynamicRange is equal to 255.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Contrast is not a property of the image but is a controlling parameter of an image manipulation algorithm. For instance, you can increase the contrast of an image by adjusting a pixel values such that the difference between light and dark is bigger.

In the real world there are images which need adjustment before being displayed perfectly, and I'm looking for automatic methods for this problem.

I uploaded some test images.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

**Note:**Source images look like MRI images, Not X-Ray ( however I could be wrong... ), with quality issues, like they are too overexposed ( captured structure of bones and, at the same time, soft tissues (!) / to capture soft tissues very low doses of radiation are needed ). I think a more complex filtering techique needs to be used based on IIR or FIR ( with some Windowing function ), or some Convolution based filtering, or something else. It is clear that some software completed a very good correction of source images. I will try a Wallis Statistical Filter but I'm Not sure that it will improve overall quality of the source image. I'll let you know as soon as my tests are completed.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

My sample images all have lightness problems since we discussed that. Applying filtering (and with that I understand structure/sharpness filtering) will not "fix" the lightning problem, unless you can tell me a nice idea of how.

Further, my images are reduced for presentation here. I could upload real 16 or 12 bpp grayscale originals, if you want.

I do not know about Wallis Statistical Filters, but I googled it, and it seems to also have use in my field, and indeed can possible help with simultanious dark and bright areas.

Can IPP perform Wallis?

I also spotted noise reduction using Wavelets, do you have an IPP code sample that demonstrates this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Yes, my sample images have original and manually adjusted lightning versions. No filtering is done (structure/sharpening), only contrast/brightness/gamma.

I'm very curious for a Wallis implementation, to test with... can be outside IPP...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

By the way, my sample images are not MRI, just simple digital 2D x-ray.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

**Wallis**implementation, to test with... can be outside IPP... Just checked IPL ( version 2.5 ) and IPP ( versions from 3.x to 7.x ) and they don't have it.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page