How to centering an Silhouette image

1 回表示 (過去 30 日間)
Kong
Kong 2020 年 3 月 11 日
コメント済み: Kong 2020 年 3 月 18 日
Hello.
I wanna centering an image (image 1 to image 2)
image 1 image 2
I got the image 1 from this code.
clear all
close all
%// read the video:
reader = VideoReader('lena_side.avi');
vid = {};
while hasFrame(reader)
vid{end+1} = im2single(readFrame(reader));
end
%// simple background estimation using mean:
bg = mean( cat(4, vid{:}), 4);
%// estimate foreground as deviation from estimated background:
fIdx = 40; %// do it for frame 43
fg1 = sum( abs( vid{fIdx} - bg ), 3 ) > 0.25;
figure;
subplot(141); imshow( bg );
subplot(142); imshow( fg1 );

採用された回答

Mahesh Taparia
Mahesh Taparia 2020 年 3 月 17 日
Hi
The image is gray scale with one object and the object is present in the right half of the image, so the usual approch could be to find the centroid of the object and shift the centroid of the object to the center of new image. New image should be the image consisting of zeros with same size of previous image.
  5 件のコメント
Mahesh Taparia
Mahesh Taparia 2020 年 3 月 18 日
編集済み: Mahesh Taparia 2020 年 3 月 18 日
Hi
You can use the regionprops function on each frame, i.e in the for loop and do the necessary computation there. Save the resultant frame inside the loop.
Kong
Kong 2020 年 3 月 18 日
Thank you so much.
I found the solution
However, I don't know how to use this in folders of images.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by