How to rescale a set of data where the maximum value needs to be the lowest of the rescaled dataset

2 次查看(过去 30 天)
I have a dataset rangin from 80 to 150, however, I need to rescale this dataset for 80 to be equal to 95% whereas 150 needs to be equal to 80%. How can I do this?

回答(1 个)

Image Analyst
Image Analyst 2023-5-25
Perhaps imadjust
help imadjust
IMADJUST Adjust image intensity values or colormap. J = IMADJUST(I) maps the values in intensity image I to new values in J such that 1% of data is saturated at low and high intensities of I. This increases the contrast of the output image J. J = IMADJUST(I,[LOW_IN; HIGH_IN],[LOW_OUT; HIGH_OUT]) maps the values in intensity image I to new values in J such that values between LOW_IN and HIGH_IN map to values between LOW_OUT and HIGH_OUT. Values below LOW_IN and above HIGH_IN are clipped; that is, values below LOW_IN map to LOW_OUT, and those above HIGH_IN map to HIGH_OUT. You can use an empty matrix ([]) for [LOW_IN; HIGH_IN] or for [LOW_OUT; HIGH_OUT] to specify the default of [0 1]. If you omit the argument, [LOW_OUT; HIGH_OUT] defaults to [0 1]. J = IMADJUST(I,[LOW_IN; HIGH_IN],[LOW_OUT; HIGH_OUT],GAMMA) maps the values of I to new values in J as described in the previous syntax. GAMMA specifies the shape of the curve describing the relationship between the values in I and J. If GAMMA is less than 1, the mapping is weighted toward higher (brighter) output values. If GAMMA is greater than 1, the mapping is weighted toward lower (darker) output values. If you omit the argument, GAMMA defaults to 1 (linear mapping). NEWMAP = IMADJUST(MAP,[LOW_IN; HIGH_IN],[LOW_OUT; HIGH_OUT],GAMMA) transforms the colormap MAP associated with an indexed image. LOW_IN, HIGH_IN, LOW_OUT and HIGH_OUT must be 1-by-3 vectors. GAMMA can be a 1-by-3 vector that specifies a unique gamma value for each channel or a scalar that specifies the value used for all three channels. The rescaled colormap, NEWMAP, is the same size as MAP. RGB2 = IMADJUST(RGB1,...) performs the adjustment on each image plane (red, green, and blue) of the RGB image RGB1. As with the colormap adjustment, you can apply unique mappings to each plane. Note that IMADJUST(I) is equivalent to IMADJUST(I,STRETCHLIM(I)). Note that if HIGH_OUT < LOW_OUT, the output image is reversed, as in a photographic negative. Class Support ------------- For syntaxes that include an input image (rather than a colormap), the input image can be uint8, uint16, int16, double, or single. The output image has the same class as the input image. For syntaxes that include a colormap, the input and output colormaps are double. Examples -------- I = imread('pout.tif'); J = imadjust(I); figure, imshow(I), figure, imshow(J) K = imadjust(I,[0.3 0.7],[]); figure, imshow(K) RGB1 = imread('football.jpg'); RGB2 = imadjust(RGB1,[.2 .3 0; .6 .7 1],[]); figure, imshow(RGB1), figure, imshow(RGB2) I = imread('pout.tif'); n = 2; % Number of standard deviations from mean to stretch to Idouble = im2double(I); avg = mean2(Idouble); sigma = std2(Idouble); J = imadjust(I,[avg-n*sigma avg+n*sigma],[]); figure, imshow(I), figure, imshow(J) See also BRIGHTEN, DECORRSTRETCH, HISTEQ, IMCONTRAST, IMHISTMATCH, STRETCHLIM. Documentation for imadjust doc imadjust Other uses of imadjust gpuArray/imadjust

标签

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by