Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 如何在不使用内置函数的情况下在matlab中翻转图像?_Image_Matlab_Grayscale_Flip - Fatal编程技术网

Image 如何在不使用内置函数的情况下在matlab中翻转图像?

Image 如何在不使用内置函数的情况下在matlab中翻转图像?,image,matlab,grayscale,flip,Image,Matlab,Grayscale,Flip,编写一个MATLAB代码,读取灰度图像并生成原始图像的翻转图像。 我正在尝试此代码,但没有给我正确的翻转图像。将非常感谢您的帮助。谢谢 clear all clc a=imread('pout.tif'); [r,c]=size(a); for i=r:-1:1 k=1; for j=1:1:c temp=a(k,j); result(k,j)=a(i,j); result(i,j)=temp; k=k+1; end end subplot(1,2,

编写一个MATLAB代码,读取灰度图像并生成原始图像的翻转图像。 我正在尝试此代码,但没有给我正确的翻转图像。将非常感谢您的帮助。谢谢

clear all
clc
a=imread('pout.tif');
[r,c]=size(a);
for i=r:-1:1
  k=1;
for j=1:1:c 
    temp=a(k,j);
    result(k,j)=a(i,j);
    result(i,j)=temp;
     k=k+1;
  end
end
 subplot(1,2,1), imshow(a)
 subplot(1,2,2),imshow(result) 

你用指数做什么还不清楚。您还应该为结果预先分配内存

clear all
clc
a=imread('pout.tif');
[r,c]=size(a);
result = a; % preallocate memory for result
for i=1:r
    for j=1:c
        result(r-i+1,j)=a(i,j);
    end
end
subplot(1,2,1), imshow(a)
subplot(1,2,2),imshow(result)

你用指数做什么还不清楚。您还应该为结果预先分配内存

clear all
clc
a=imread('pout.tif');
[r,c]=size(a);
result = a; % preallocate memory for result
for i=1:r
    for j=1:c
        result(r-i+1,j)=a(i,j);
    end
end
subplot(1,2,1), imshow(a)
subplot(1,2,2),imshow(result)

可以使用基本索引翻转矩阵。2D案例(灰度图像):

对于3D案例(彩色图像),添加第三个索引

a = a(:,end:-1:1,:); % horizontal flip

可以使用基本索引翻转矩阵。2D案例(灰度图像):

对于3D案例(彩色图像),添加第三个索引

a = a(:,end:-1:1,:); % horizontal flip

非常感谢。非常感谢。这是家庭作业问题吗?我不明白为什么不能使用内置函数?这是家庭作业问题吗?我不明白为什么不能使用内置函数?