📄 replacergbvalue.m
字号:
function Y = replaceRGBValue(X, value2rep, with_values)
% replaceRGBValue A value is replaced in an image matrix
% A certain value is replaced by several values (for each dimension a
% value is possible) in an image matrix (dimension>2).
%
% Inputs:
% * X ... uint8 nxm matrix (m>2)
% * value2rep ... a single value which is to replace
% * with_values ... the values to put instead (for dimension a value)
%
% Outputs:
% * Y ... uint8 nxm matrix with replaced value
%
% Example
% Given is an uint8 image matrix (which was loaded with imread), with
% |Y = mirrorImage(X)| you get the image upside down.
%
% See also: mirrorImage, image, imread
%
%% Signature
% Author: W.Garn
% E-Mail: wgarn@yahoo.com
% Date: 2006/03/23 12:00:00
%
% Copyright 2006 W.Garn
%
dim = size(X);
Y=[];
if length(dim)>2
Y=zeros(dim);
for d=1:dim(3)
Y(:,:,d) = uint8((X(:,:,d)==value2rep)*with_values(d))+uint8((X(:,:,d)~=value2rep)).*X(:,:,d);
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -