在 MATLAB 中翻转和旋转彩色图像 [英] flip and rotate a color image in MATLAB

查看:51
本文介绍了在 MATLAB 中翻转和旋转彩色图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 MATLAB 中翻转彩色图像 (RGB)?fliplr 似乎无法在不丢失颜色内容的情况下工作,因为它只处理 2D.

How do I flip a color image (RGB) in MATLAB? The fliplr does not seem to work without losing the color contents, as it only deals with 2D.

同样,imrotate 可能不会旋转彩色图像.

As well, the imrotate may not rotate color images.

推荐答案

函数 flipdim 适用于 ND 矩阵,而函数 flipudfliplr 仅适用于二维矩阵:

The function flipdim will work for N-D matrices, whereas the functions flipud and fliplr only work for 2-D matrices:

img = imread('peppers.png');     %# Load a sample image
imgMirror = flipdim(img,2);      %# Flips the columns, making a mirror image
imgUpsideDown = flipdim(img,1);  %# Flips the rows, making an upside-down image

注意:在较新版本的 MATLAB(R2013b 和更新版本)中,函数 flip 现在推荐代替 flipdim.

NOTE: In more recent versions of MATLAB (R2013b and newer), the function flip is now recommended instead of flipdim.

这篇关于在 MATLAB 中翻转和旋转彩色图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆