Dr.*_*lan 1 matlab image-processing
我想用MATLAB提取图像的反转绿色通道响应.我已经实现了它,但我不知道它是否正确.我将非常感谢你的帮助.
y = x(:, :, 2); %green channel
z=255-y; % inverted green channel
Run Code Online (Sandbox Code Playgroud)
一种更通用的方法
%// Green channel
y = x(:, :, 2);
%// Invert the green
if isinteger(y)
z = intmax(class(y))-y;
elseif isfloat(y)
z = 1 - y;
elseif islogical(y)
z = ~y;
else
error('Strange image you''ve got there...');
end
Run Code Online (Sandbox Code Playgroud)
注意:这假设图像是RGB颜色空间,此外,如果它是类float
,它假定值被标准化为1.如果可能有不同,您可能需要更多检查.
在任何情况下:记录这些限制!