1
대각선으로 행렬 셀을 어떻게 시프트 할 수 있습니까? 나는 수평 라인 이미지가matshut/octave에서 대각선 방향으로 martix를 이동하기 위해 서큘 레프트 사용
내가 대각선 세포를 이동하는 코드의 조각을 사용
reshaped_output = imresize(repmat_rgb, [640, 480]); %reshape output
imwrite(reshaped_output,strcat('/tmp/img/','orig','.png')); %will create file without borders and use any resize in repmat
[row, col, dim] = size(reshaped_output);
diag_shift_rgb=zeros(row, col, dim); %preallocate array
for ii=1:col
bb_r=circshift(reshaped_output(:,ii,1),ii-1);
bb_g=circshift(reshaped_output(:,ii,2),ii-1);
bb_b=circshift(reshaped_output(:,ii,3),ii-1);
diag_shift_rgb(:,ii,1)=[bb_r]; %over write array
diag_shift_rgb(:,ii,2)=[bb_g]; %over write array
diag_shift_rgb(:,ii,3)=[bb_b]; %over write array
end
imwrite(diag_shift_rgb,strcat('/tmp/img/','diag','.png')); %will create file without borders and use any resize in repmat
아래 내가 대각선 이동합니까 참조 선들은 색이 바뀌지 만 내가 잘못하고있는 것은 무엇입니까?
시 : 나는
Input Example with numbers
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
5 5 5 5
6 6 6 6
7 7 7 7
Output example with numbers of what I'm trying to get with the image
1 7 6 5
2 1 7 6
3 2 1 7
4 3 2 1
5 4 3 2
6 5 4 3
7 6 5 4
예상되는 결과는 무엇입니까? – rahnema1
@ rahnema1 그들이해야 할 때 색상이 밀접하게 일치하지 않으며 사용자가 보이는 것을 보면 입력보다 출력에 흰색이 더 많이 보입니다. 선은 대각선 방향으로 진행되어야하며 출력 배열 크기도 원래 배열 크기와 동일해야합니다. –
@ rahnema1 숫자가있는 또 다른 예를 추가했습니다. 대각선 기울기 (1과 2를 보라)를 주목하라. 나는 색깔 선과 똑같이하려고 노력하고있다. –