Shifting an image using matrix manipulation.
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi, I have a codeline that shifts an image 240 pixels horizontally. I used the code from an example in my class, however they do it in grayscale and I want to keep the shifted image in the original color. What do i have to modify in order to keep the same color as the original image.
Here's the code:
if true
% code
function [] = hshift
X=imread('photo1.jpg');
X_double=double(X);
red_channel_X= X_double(:,:,1);
green_channel_X=X_double(:,:,2);
blue_channel_X=X_double(:,:,3);
X1=.3*red_channel_X+.3*green_channel_X+.4*blue_channel_X;
colormap('default')
[m,n]=size(X1);
r=240;
E=eye(n);
T=zeros(n,n);
T(:,1:r)=E(:,n-(r-1):n);
T(:,r+1:n)=E(:,1:n-r);
X_shift=X1*T;
imagesc(uint8(X_shift));
colormap('default');
end
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!