Shifting an image using matrix manipulation.
7 ビュー (過去 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!