PDA

查看完整版本 : 在MATLAB中翻转和旋转彩色图像


poster
2019-12-10, 20:48
如何在MATLAB中翻转彩色图像(RGB)? fliplr似乎在不丢失颜色内容的情况下不起作用,因为它仅处理2D。

同样, imrotate可以不旋转的彩色图像。



回答:

函数flipdim (http://www.mathworks.com/help/matlab/ref/flipdim.html)适用于ND矩阵,而函数flipud (http://www.mathworks.com/help/matlab/ref/flipud.html)和fliplr (http://www.mathworks.com/help/matlab/ref/fliplr.html)仅适用于二维矩阵:

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 (http://www.mathworks.com/help/matlab/ref/flip.html)而不是flipdim (http://www.mathworks.com/help/matlab/ref/flipdim.html) 。



更多&回答... (https://stackoverflow.com/questions/4010113)