how to make the background of an image transparent?
이전 댓글 표시
I'm having a bird image with white background..and i need to make the background transparent so that i can add it to a block of the sky image naturally. Can anyone please help me to do it in Matlab..Thanks in advance..
댓글 수: 2
Daniel Shub
2013년 1월 23일
This might be related to this question or are you trying to take an image (say a png file), process it, and create a new image (also a png file)?
Daniel Shub
2013년 1월 23일
EDIT Moved answer to comments john-john said: how can we help or suggest you.. you didn't post your picture =)
답변 (2개)
Image Analyst
2013년 1월 23일
Extract color channels of each RGB image:
% Extract the individual red, green, and blue color channels.
redChannel = rgbBirdImage(:, :, 1);
greenChannel = rgbBirdImage(:, :, 2);
blueChannel = rgbBirdImage(:, :, 3);
skyRedChannel = rgbSkyImage(:, :, 1);
skyGreenChannel = rgbSkyImage(:, :, 2);
skyBlueChannel = rgbSkyImage(:, :, 3);
For each color channel, threshold
bird = greenChannel < threshold; % Create binary mask image.
Then do the replacement:
skyGreenChannel(bird) = greenChannel(bird); % Replace with bird pixels.
Then recombine:
compositeImage = cat(3, skyRedChannel, skyGreenChannel, skyBlueChannel);
Walter Roberson
2013년 1월 23일
Create a logical array BirdMask that is true for pixels that you want to continue to show, and false for background pixels. Display the sky image first. Then
image(BirdImage, 'AlphaData', BirdMask)
댓글 수: 1
Raseen Akhtar
2015년 12월 4일
How would I get the logical array BirdMask?
카테고리
도움말 센터 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!