MATLAB Answers

Image Background Overlay Color Changes Why Does It happen?

1 view (last 30 days)
Mir AbdulRehman
Mir AbdulRehman on 12 Feb 2021
Answered: Selva Karna on 4 Mar 2021
Hi i just Worked on an Assignment and Im having some deficulties with it.....Canany one check whats wrong...
Note: Assignment is to modify the background image to display a Logo on it.
something like this,
I'm still new with Matlab please can anyone help me with this...
The code I have been working is the following.
% Some of the Functons were written in the assignment to use specifically like im2double and more.
% the starting is simple reading the image, resizing the logo image, and converting it to im2double, im2bw (Part of the assignment).
%I faced issues on the third where i have to use condition and for loop to chane the pixals valse one-by-one to display the logo
% on the background.
% Please help me with this assignment...
Bgimg = imread("Background_Image.jpg");
Bgimgdouble = im2double(Bgimg);
Fgimg = imread("Forground_Image.png");
FgimgRs = imresize(Fgimg, [576 720]);
% converting White and Black to Black and White.
FgimgRsComp = imcomplement(FgimgRs);
Fgimg2bw = im2bw(FgimgRsComp, 0.4);
%Here im having some trouble
img = zeros(size(Fgimg2bw));
for ii=1:size(Fgimg2bw,1)
for jj=1:size(Fgimg2bw,2)
% get pixel value
% check pixel value and assign new value
if pixel<0.5
elseif pixel>3
new_pixel = pixel;
% save new pixel value in img image
% When Place the image on to each other the logo image (VU) turns Blue instead of white.
% Also i wanted the logo to be transparent.
axis image
hold on
im = image(img);
im.AlphaData = max(img,[],3);
hold off
This is the Result im getting.....

Community Treasure Hunt

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

Start Hunting!