# function imr=imscale(im,maxv,minv)

The function ** imscale(im,maxv,minv)** linearly rescales an image

**between 1 and 0 so that**

`im`**corresponds to a 1 and**

`maxv`**corresponds to a 0**

`minv`In this example we have an original image ** im**, with the main structure has

**and**

`minv = 150`**. Note that we didn't choose the maximum value in the colorbar (i.e. 400) as**

`maxv = 350`**. Since there are only a few points with that high values, these pixels may be affected by instrumental error.**

`maxv`imagesc(im) colorbar

The first step of normalization is to subtract ** im** by

**, so the minimum value of the interesting structure is**

`minv`**. The second step is to divide the subtracted image by the normalizing factor**

`0`**, so that the maximum value of the structure is**

`maxv-minv`**. Combine these two steps, we have**

`1`imr=(im-minv)./(maxv-minv); imagesc(imr) colorbar

Now the whole image is rescaled to values near the range ** (0,1)**, but there still are some pixels with negative values, or have values larger than 1. Therefore the last part of rescaling
is to smooth the remaining pixels with either

**or**

`0`**:**

`1`imr(imr<0)=0; imr(imr>1)=1;

Then we have the neat rescaled image, with the main structure emphasized:

imagesc(imr) colorbar