imtranslate command matlab shows me a black image

5 ビュー (過去 30 日間)
alessiadele
alessiadele 2019 年 1 月 14 日
回答済み: PARVATHY M 2021 年 8 月 3 日
Hi everyone!
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.
Thank you!
  1 件のコメント
PARVATHY M
PARVATHY M 2021 年 8 月 3 日
Hello! I'm trying to translate an image that is read using imread.
The code is; f=imread('C:\users\hp\Desktop\rbcimg.jpg'); I=rgb2gray(f); J=imtranslate(f,[20,25]); plot,imshow(J)
But an error is appearing showing that, undefined function or method 'imtranslate' for input arguments of type 'uint8' So how to rectify this? My matlab version is R2010a 7.10.0 Plase help!!

サインインしてコメントする。

採用された回答

Omer Yasin Birey
Omer Yasin Birey 2019 年 1 月 14 日
編集済み: Omer Yasin Birey 2019 年 1 月 14 日
It would be much better if you shared your image. Anyway, probably imtranslate doesn't return black image, the blackness comes from your original image(I mean some parts are black) and you just take the indexes where the blackness occur when trying to bound the imtranslate. You said you want to place the origin at the center so if you don't want to save the image data you may use this.
fingers=imread('thumb-index.png');
[nrows,ncols] = size(fingers);
RI = imref2d(size(fingers));
h = imshow(fingers,RI);
grid on
minFind = (min(ncols,nrows));
[fingers_translate,RF]=imtranslate(fingers,RI,[300,400]);
figure
imagesc([-minFind,minFind],[-minFind,minFind],fingers)
grid on
  1 件のコメント
alessiadele
alessiadele 2019 年 1 月 14 日
Yes, I tried to modify the code as you said, and now it works!
Thank you :D

サインインしてコメントする。

その他の回答 (1 件)

PARVATHY M
PARVATHY M 2021 年 8 月 3 日
Hello! I'm trying to translate an image that is read using imread. The code is; f=imread('C:\users\hp\Desktop\rbcimg.jpg'); I=rgb2gray(f); J=imtranslate(f,[20,25]); plot,imshow(J) But an error is appearing showing that, undefined function or method 'imtranslate' for input arguments of type 'uint8' So how to rectify this? My matlab version is R2010a 7.10.0 Plase help!!

カテゴリ

Help Center および File ExchangeLanguage Support についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by