📄 remapim.m
字号:
% REMAPIM - Remaps image intensity values%% Usage: newim = remapim(im, x, y, rescale)% \% optional% Arguments% im - Image to be transformed.% x,y - Coordinates of spline control points that define the% mapping function. These coordinates are in the range% 0-1 and are typically obtained experimentally via the% function GREYTRANS% rescale - An optional flag (0 or 1) indicating whether image% values should be normalised to the range 0-1. % This is only provided for speed when called% by GREYTRANS. By default the input image will% be normalised to the range 0-1.%% Image intensity values are remapped to new values via a mapping% function defined by a series of spline points. The mapping function is% defined over the range 0-1, accordingly the input image is normalised% to the range 0-1. The output image will also lie in this range. function nim = remapim(im, x, y, rescale) if nargin < 4 rescale = 1; end if ndims(im)==3 % Assume we have a colour image hsv = rgb2hsv(im); % Apply remapping just to the value component hsv(:,:,3) = remap(hsv(:,:,3), x, y, rescale); nim = hsv2rgb(hsv); else % Assume we have a 2D greyscale image nim = remap(im, x, y, rescale); end% Internal function that does the workfunction nim = remap(im, x, y, rescale) if rescale im = normalise(im); end nim = spline(x,y,im); % Remap image values % clamp image values within bounds 0 - 1 gt0 = nim > 0; nim = nim.*gt0; % values < 0 become 0 lt1 = nim < 1; nim = nim.*lt1 + ~lt1; % values > 1 become 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -