Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

I have data relative to image intensity, which range from 0 to 255. For some models I need to run, I must transform this intensity data to a different scale, which must have a certain mean (for example, 1.5) and a certain maximum (for this example, 2). I have found information on how to convert data to a scale based on a min and a max, and also to a scale which has a given mean and variance, but these don't apply to my case - I just want to specify the mean and the maximum, deriving other properties from the data distribution.

Any ideas?

Many thanks!

share|improve this question

2 Answers 2

Let the mean of your sample be $\bar{x}$ and the desired mean be $\bar{y}$. Also, $x_{(n)}$ is your sample maximum and $y_{(n)}$ is the desired maximum. Then, create a transformation of your data $y=ax + b$ such that $\bar{x}$ corresponds to $\bar{y}$ and $x_{(n)}$ corresponds to $y_{(n)}$:

$$\begin{align*} a &= \frac{y_{(n)}-\bar{y}}{x_{(n)}-\bar{x}} \quad \text{and} \\ b&=\bar{y}-a\bar{x}. \end{align*}$$

Note that this is just a line through the points $(\bar{x},\bar{y})$ and $(x_{(n)},y_{(n)})$. It requires that $x_{(n)} \neq \bar{x}$, essentially implying that $x$ must have positive variance.

Since this is a linear transformation, deriving properties of the distribution of $y$ using the distribution of $x$ (other than the mean and maximum) should be easy.

Hope that helps.

share|improve this answer
    
@whuber, you are absolutely right. In my answer, I assumed both that $x_{(n)} \neq 0$ and $\alpha > 0$. If you want to post your comment as an answer, I'll delete my answer. –  Charlie Mar 4 '11 at 21:21
1  
Why not just edit your answer? As I said, your idea is correct, so you just need to fix the formula. Then I can vote it up :-). –  whuber Mar 4 '11 at 21:32
1  
@whuber, I didn't want to take any credit from you. Thanks for the assist! –  Charlie Mar 4 '11 at 21:46
    
I fixed it up for you :-). –  whuber Mar 4 '11 at 21:53

Transforming based on maximum/minimums is dangerous because outliers can drastically affect the scaling. For example, if you have an image mostly in the 10-50 range, with a couple of noisy points in the 250 range, you will be adjusting the image based on a questionable maximum, hurting the dynamic range.

I think it would be safer to adjust your image based on mean/median and variance, and then cap the maximum (clipping). For example, you can set the variance so the vast majority of data points in your typical image would fall in the range you desire, and cap anything that goes above it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.