mirrorimage.m

来自「国际象棋程序,解压到当前目录,在matlab窗口输入chess即可应用」· M 代码 · 共 33 行

M
33
字号
function Y = mirrorImage(X)
% mirrorImage  do X upside down.
% reverses the direction of the given image
%
% Inputs:
% * X ... uint8 nxm matrix (n,m>1)
%
% Outputs:
% * Y ... uint8 nxm matrix up side down
%
% Example
% Given is an uint8 image matrix (which was loaded with imread), with 
% |Y = mirrorImage(X)| you get the image upside down.
%
% See also: fliplr, 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);
if length(dim)>2
    Y = zeros(dim);
    for k=1:dim(3)
        Y(:,:,k) = (fliplr(X(:,:,k)'))';
    end
    Y = uint8(Y);
else
    Y = uint8((fliplr(X'))');
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?