'Paste' a binary image onto a background image? (image blending)

3 vues (au cours des 30 derniers jours)
computing6
computing6 le 26 Avr 2015
Project is to take a picture of myself, make it into a binary image (background around me all white, my body is completely black), then I have to pretty much paste that image onto a background. My goal is to create a function (x-y coordinates) that returns the first picture (me) on top of the second picture (the background). I have to choose a spot to place the picture of me also.
Can someone just give me pseudo code or something just so i have an idea of where to start/how to do it? I'm so lost :(

Réponses (1)

Image Analyst
Image Analyst le 27 Avr 2015
I don't understand. If the original picture is on top of the background, how can the background even be seen? Some part of your original picture must be transparent. If it's where the binary image is all white, then for a gray scale image, do
grayImage(binaryImage) = 255;
If you have a color image, then do it for every color channel.
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Multiply the mask by each color channel individually.
redChannel(mask) = 255;
greenChannel(mask) = 255;
blueChannel(mask) = 255;
% Recombine separate masked color channels into a single, true color RGB image.
maskedRgbImage = cat(3, redChannel, greenChannel, blueChannel);

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by