3
$\begingroup$

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!

$\endgroup$

2 Answers 2

12
$\begingroup$

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.

$\endgroup$
4
  • $\begingroup$ @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. $\endgroup$
    – Charlie
    Commented Mar 4, 2011 at 21:21
  • 1
    $\begingroup$ 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 :-). $\endgroup$
    – whuber
    Commented Mar 4, 2011 at 21:32
  • 1
    $\begingroup$ @whuber, I didn't want to take any credit from you. Thanks for the assist! $\endgroup$
    – Charlie
    Commented Mar 4, 2011 at 21:46
  • $\begingroup$ I fixed it up for you :-). $\endgroup$
    – whuber
    Commented Mar 4, 2011 at 21:53
1
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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