フィルターのクリア

Hi, someone can help me how to do "translation" in image ?

2 ビュー (過去 30 日間)
yovel atia
yovel atia 2021 年 9 月 13 日
回答済み: Image Analyst 2021 年 9 月 13 日
Hi
i need to do "translation" in image, but i don't found how to do that.
i need to take selfie image and then to center my face in the photo.
like this:
TNX!!

採用された回答

Walter Roberson
Walter Roberson 2021 年 9 月 13 日
I = imread('cameraman.tif');
imshow(I)
BW = imbinarize(I);
L = bwareafilt(~BW, 1);
props = regionprops(L, 'Centroid');
CR = props.Centroid(2);
CC = props.Centroid(1);
hold on
plot(CC, CR, '+r', 'markersize', 20);
hold off
[R, C, P] = size(I);
rows_to_shift_down = floor(R/2 - CR);
cols_to_shift_right = floor(C/2 - CC);
J = circshift(I, [rows_to_shift_down, cols_to_shift_right]);
imshow(J)
%cross-check only, centroid should now be at center
BW = imbinarize(J);
L = bwareafilt(~BW, 1);
props = regionprops(L, 'Centroid');
CR = props.Centroid(2);
CC = props.Centroid(1);
hold on
plot(CC, CR, '+r', 'markersize', 20);
hold off
Yup, looks okay.
  1 件のコメント
yovel atia
yovel atia 2021 年 9 月 13 日
It works :)
Thank you !!!

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2021 年 9 月 13 日
Description
B = imtranslate(A,translation) translates image A by the 2-D or 3-D translation vector specified in translation.
If A has more than two dimensions and translation is a 2-element vector, then imtranslate applies the 2-D translation to each plane of A.

カテゴリ

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

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by