Question: MATLAB Hello! I'm currently working on a program that will hide an image in another. I am on part 2, but cannot get it to
MATLAB
Hello! I'm currently working on a program that will hide an image in another. I am on part 2, but cannot get it to work when I click Odd/Even Red Embedding. I have included the prompt, code, and GUI. Any help is appreciated, thank you!

Function as stated in part 1:
function [BW] = flatten(img)
I = imread(img);
BW = imbinarize(I);

Won't display embedded image in 4th column.
code in text:
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
normalImg = getimage(handles.axes1);
hiddenImg = getimage(handles.axes2);
flatHiddenImg = flatten(hiddenImg);
normalRedCh = normalImg(:,:,1);
[r,c] = size(flatHiddenImg);
for i=1:r
for j=1:c
if (flatHiddenImg(i,j) == 0) % If pixel is white
if (mod(normalRedCh(i,j),2) == 0) % If normal image has an even value,
normalRedCh(i,j) = normalRedCh(i,j) - 1; % then subtract 1 to make odd.
else % If normal image has an odd value.
normalRedCh(i,j) = normalRedCh(i,j) - 0; % subtract 0 to keep odd.
end
elseif (flatHiddenImg(i,j) == 1) % If pixel is black
if (mod(normalRedCh(i,j),2) == 0) % If dog image has an even value,
normalRedCh(i,j) = normalRedCh(i,j) - 0; % then subtract 0 to keep even.
else % If dog image has an odd value
normalRedCh(i,j) = normalRedCh(i,j) - 1; % then subtract 1 to make even.
end
end
end
end
normalImg = normalRedCh;
axes(handles.axes3);
imshow(normalImg);
Part 1: Flattening the Images There is an image dog.png, which you will be concealing at least 10 hidden images in. Try viewing it with
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
