필터 지우기
필터 지우기

How do I combine two images of different sizes like a photo frame?

조회 수: 6 (최근 30일)
Magesh Anand
Magesh Anand 2017년 8월 13일
댓글: Image Analyst 2017년 8월 14일
I have two Images DSLR (My Photo and Photo frame), I need to make a photo frame for that i don't know how to combine both without any pixel loss. Kindly help me
  댓글 수: 2
KSSV
KSSV 2017년 8월 13일
Why don't you attach your images and give a expected output?
Magesh Anand
Magesh Anand 2017년 8월 13일
I want the photo inside the frame

댓글을 달려면 로그인하십시오.

답변 (2개)

Chad Greene
Chad Greene 2017년 8월 13일
Here's a quick and dirty way.
% Load images:
man = imread('john-cena-3.jpg');
frame = imread('Transparent_Easter_Frame.png') ;
% Make the frame the same size as the man:
framer = imresize(frame,[size(man,1) size(man,2)]);
% Find empty region of the frame (where all RGB values are zero):
whiteRegion = sum(framer,3)==0;
% For context, here's the white region of the frame:
imagesc(whiteRegion)
axis off
% Display the picture of the man:
figure
image(man)
% Overlay the picture of the resized frame:
hold on
h = image(framer);
% Make the white region of the frame transparent:
set(h,'AlphaData',~whiteRegion);
axis image off
  댓글 수: 1
Image Analyst
Image Analyst 2017년 8월 14일
I think you could make an RGB image like this:
output = frame; % Initialize;
mask = cat(3, whiteRegion, whiteRegion, whiteRegion);
output(mask) = man(mask); % Replace white with man but only in mask region.
imshow(output);

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2017년 8월 14일
See my attached copy and paste demos.

Community Treasure Hunt

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

Start Hunting!

Translated by