How to extract the hand out of the background? (homework assignment)

2 vues (au cours des 30 derniers jours)
Tu Nguyen
Tu Nguyen le 12 Mar 2022
Modifié(e) : DGM le 12 Mar 2022
Dear all, I want 'my output' image like exactly 'ouput' image. I followed step by step on the intrunction posted here.
Can anyone help me please?
close all;
clear all;
I1 = imread('hands.png');
I2 = imread('balcony.png');
gr = im2gray(I1);
threshold_value = graythresh(gr);
bw = im2bw(gr);
binary = bw<threshold_value;
binary_I = imfill(binary,'holes');
mask = I1;
mask(~bw) = 0;
ig = im2gray(mask);
output = bitand(ig,I2);
  2 commentaires
Tu Nguyen
Tu Nguyen le 12 Mar 2022
Yes sir, I already read and upload the images. If you know, please help me fix the code

Connectez-vous pour commenter.

Réponse acceptée

DGM le 12 Mar 2022
Modifié(e) : DGM le 12 Mar 2022
If you're trying to create the composite image:
FG = imread('');
BG = imread('');
mask = FG<210; % basic thresholding
outpict = uint8(double(FG).*mask + double(BG).*(~mask)); % compose image
Alternatively, you can go to extra lengths to improve the masking:
mask = FG<210; % same thresholding
mask = imerode(mask,ones(7)); % shrink mask to remove edge banding
mask = imgaussfilt(double(mask),1.5); % feather mask back toward original edges
outpict = uint8(double(FG).*mask + double(BG).*(1-mask)); % compose

Plus de réponses (0)




Community Treasure Hunt

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

Start Hunting!

Translated by