Search code examples
imagematlabcoordinatessystem

imtranslate command matlab show me a black image


I'm trying to translate an image read through imshow function, but the output is a black image.

Here's the code:

fingers=imread('thumb-index.png');

[nrows,ncols] = size(fingers);

RI = imref2d(size(fingers));
h = imshow(fingers,RI);
grid on

x_center=ncols/2;
y_center=nrows/2;

x_orig=ncols-x_center;
y_orig=nrows-y_center;

[fingers_translate,RF]=imtranslate(fingers,RI,[x_orig,y_orig]);
figure

h=imshow(fingers_translate,RI);
grid on 

My target is translating the origin of coordinate system in the center of the image. Thanks!


Solution

  • you pushed the image out of frame. To see translation effect try:

    x_orig=100;
    y_orig=100;