Please let me know if i want column shuffling instead of rows what changes i must need in this code.
% for the color image, for even rows and cols
% Need to perform switching of rows at each channel
A = imread('Untitled.png');
[m, n, c] = size(A);
temp= zeros(m,n);
for i = 1 : c
A1 = A(:, :, i);
a1 = A1(1 : m/2, :);
a2 = A1(end: -1 : m/2+1, :);
temp(1:2:end,:) = a1;
temp(2:2:end,:) = a2;
A(:, :, i) = temp;
end

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2015년 3월 12일
편집: Andrei Bobrov 2015년 3월 12일

0 개 추천

A = imread('Untitled.png');
m = size(A);
out = zeros(m);
m1 = round(m(2)/2);
out(:,1:2:end,:) = A(:,1:m1,:);
out(:,2:2:end,:) = A(:,end:-1:m1+1,:);

추가 답변 (1개)

Michael Haderlein
Michael Haderlein 2015년 3월 12일
편집: Guillaume 2015년 3월 12일

0 개 추천

Please use the {}Code button to make your code readable.
If this code is sorting the rows in the manner you want, you can change it to do the same with columns this way:
A = imread('Untitled.png');
[m, n, c] = size(A);
temp= zeros(m,n);
for i = 1 : c
A1 = A(:, :, i);
a1 = A1(:, 1 : n/2);
a2 = A1(:, end: -1 : n/2+1);
temp(:, 1:2:end) = a1;
temp(:, 2:2:end) = a2;
A(:, :, i) = temp;
end

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

질문:

2015년 3월 12일

편집:

2015년 3월 12일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by