randomal
randomal

Reputation: 6592

MATLAB - translate colour image from file

I have a colour PNG image and I need to translate it and plot the result, which should have the same colour scale of the original image. Using the code below I get as a result a greyscale image; do you know how to fix this? Thanks!

[E_col, map_E] = imread('E.png');
shift_vert = 35; % 152
shift_hor = 30;
E_col_shift = zeros(size(E_col,1) + shift_vert, size(E_col,2) + shift_hor);
E_col_shift = imtranslate(E_col_shift,[shift_hor, shift_vert]);
figure; imshow(E_col_shift, map_E);

Here you can find the image I am working with:enter image description here

Upvotes: 0

Views: 52

Answers (1)

Ander Biguri
Ander Biguri

Reputation: 35525

You have a typografical error:

% // This image is JUST ZEROES!!!!!!!!!!!!!!!!!!!!!!!!!!
E_col_shift = zeros(size(E_col,1) + shift_vert, size(E_col,2) + shift_hor);


%// So why are you translating the empthy image?!?!?!
E_col_shift = imtranslate(E_col_shift,[shift_hor, shift_vert]);

%// It should be the original image!!!!!
E_col_shift = imtranslate(E_col,[shift_hor, shift_vert]);

Upvotes: 1

Related Questions