Shifting an image using matrix manipulation.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Odom Seng
el 30 de Jun. de 2016
Respondida: Image Analyst
el 30 de Jun. de 2016
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 comentarios
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Image Segmentation and Analysis en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!