# Re: How to calculate contrast in different parts of an image in Matlab?

*From*: Angelo Campanella <a.campanella@xxxxxxx>*Date*: Tue, 10 Oct 2006 00:56:23 GMT

Predictor wrote:

I don't know whether there exists a conventional mathematical

definition of "contrast", but I would think that any decent measure of

dispersion (image in X: var(X(:)) or std(X(:)) in MATLAB base or

iqr(X(:)) in the Statistics Toolbox) might serve as a reasonable

measure of contrast.

Do I read his right? Is it that the modern defintiion of contrast is now the standard deviaton (or alteratively, variation) of the optical-electronic video signal? In days gone by, that metric would be called "contrast ratio", I believe, and would be the ratio of the maximum to the minimum brightness (inthe real world); while the electrical signal would be well, whatever it is; whether the image sensor transfer function (delta voltage per delta brightnes) is linear, or square law, or square root, or some other power.

I have intermediate knowledge about Matlab , but very basic about the

image processing tooolbox and I have a project due in a couple of

weeks. I have to find out 7 to 10 points of high contrast in a colored

I don't have much clue as to how to approach this thing because I dont

know how to calculate contrast of a region. I read about the image

processing toolbox but couldn't find much help.

Most (all?) digital codes are devoid of any physical reality. They are all "virtual" and no "reality". You as the daddy of system under development, have to do all the physics and the elementary math, then weave those into an operational code; your creation.

In my opinion, you go out and get those 7 to 10 points by honest physics methods, plot the curve, estimate the power of the curve that matches it, then coin that in matlab as Y=X^n, where n is determined as avove. You also need to get the feel of the maximum and brightness the electrooptical chain can tolerate consistently, and the minimum brightness (essentially the opto-electronic "noise floor").

>>( I was thinking of taking a window size of say 23x23 pixels, and

calculate local contrast all over the image, and then sort out my

results in descending order and choose the first 10 values and its

corresponding pixel location...but how to calculate contrast?)

It may be amatter of semantics. What do "THEY" mean by "Contrast" in your system? They might mean contrast limits (the greatest and the least brightness wanted to be processed without saturation; no delta Y for any more delta X). (The operative word is "wanted"; it may not be neccessary or even desirable, to process glinting highlihts, or depicting shadow detail beyond certain limits, which you as the daddy get to declare.)

The monotonic functons described so far, have more to do with the old photographic concept of "gamma". The math fuctions (variance, stadard deviaion) are really another measure of max/min or 'constrast ratio'. Thus, avariance of 10 units, when the scenery videa was a pure sine wave, would be a contrast ratio of 10*2*sqrt(2), or 28.3.

Angelo Campanella

.

**Follow-Ups**:**Re: How to calculate contrast in different parts of an image in Matlab?***From:*makc.the.great@xxxxxxxxx

**References**:

- Prev by Date:
**Blob Analysis** - Next by Date:
**7429-start your own home based business just $5** - Previous by thread:
**Re: How to calculate contrast in different parts of an image in Matlab?** - Next by thread:
**Re: How to calculate contrast in different parts of an image in Matlab?** - Index(es):