필터 지우기
필터 지우기

How to shift rows in a matrix by consecutive values (e.g row one 0, second row one space, third row two spaces )

조회 수: 1 (최근 30일)
I am having trouble with a video and i need to get straight every frame of it. The frames are shifted. Herein the matrix, it contains the RGB components for a frame.

답변 (2개)

Image Analyst
Image Analyst 2017년 12월 29일
Since the very frist row is the only one that gets overwritten, and the last time it gets overwritten will be the Nth row which gets put into the (N-1)st row (which is again the first row), your final image will be
rgbImage(1, :, :) = rgbImage(end, :, :);
Now, if you had said "second frame gets shifted up 2 lines, third frame gets shifted up 3 lines" then that is a completely different thing that what you asked about only shifting the second row, the third row, etc.

Image Analyst
Image Analyst 2017년 12월 29일
To shear an image sideways, see the help/demo for imwarp():
% Apply Horizontal Shear to Image
% Read grayscale image into workspace and display it.
% I = imread('cameraman.tif');
I = imread('peppers.png');
subplot(1, 2, 1);
imshow(I)
% Create a 2-D geometric transformation object.
tform = affine2d([1 0 0; .5 1 0; 0 0 1])
% Apply the transformation to the image.
J = imwarp(I,tform);
subplot(1, 2, 2);
imshow(J)
% Copyright 2015 The MathWorks, Inc.
Make easy adaptations to shear it the other direction.
  댓글 수: 1
Miguel Reina
Miguel Reina 2018년 1월 3일
This is what i was looking for
id=0:576;
out=cell2mat(arrayfun(@(x) circshift(mat(x,:),[1 id(x)]),(1:numel(id))','un',0));
%mat is the matrix i want to shift and its size is 577 by 721.
thanks anyway

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Geometric Transformation and Image Registration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by