1
どのように行列セルを斜めにシフトできますか? martix/octaveで斜めにシフトするために循環シフトを使用する
私はセルをシフトするためのコードスニペットを使用して斜めに私は対角シフトのですか
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を見てください)私はカラーラインで同じことをしようとしています –