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);
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 . 1. 2. There are ten images labeled hiddenXXpng with XX from 1 to 10. Let's take the grayscale hidden image and make it black and white: a. Load one of the hidden images. It should be in a 400x400 integers matrix (grayscale). b. Create a function to "Flatten" the image by creating a 400x400 matrix with values "1" if the corresponding hidden image pixel is dark and "O" if the pixel is light (black&white) Your threshold for dark/light is up to you as long as the image is still distinguishable after converting from grayscale to black&white Create a function to "Expand" the flattened image by taking the 400x400 flattened image and creating a new RGB image with black pixels for "1" elements, and white pixels for "O" elements Test by Flattening and Expanding one of the images and making sure it can be displayed properly with the simage> command. c. Part 2: Create Embedding Techniques As an example for one of the techniques that can be used is the odd/even embedding technique This is an example one of the different techniques that you will use to hide all the black and white images into the concealing image. The flattened hidden image is a 400x400x1 matrix of values 0 (white) and 1 (black) pixels. The normal image is a 400x400x3 matrix of values 0-255, representing the values of the red, green, and blue channels. Our first embedding technique goes as follows: 1. 2. 3. Use your "Flattening" function from part 1 to flatten the hidden image selected by the user to a flattened hidden image If flattened hidden image pixel (x.y) is black, make the red channel of pixel (x.y) in the normal image odd valued by either subtracting zero or one. If flattened hidden image pixel (x,y) is white, make pixel (x.y) on the red channel of the normal
i modified code so far
code in text:
% --- Executes on button press in pushbutton3.

MATLAB

Hello! I’m currently launched on a program that earn cloke an representation in another. I am on segregate 2, notwithstanding cannot acquire it to production when I click Sole/Equal Sanguine Embedding. I enjoy moderate the ready, jurisprudence, and GUI. Any succor is appreciated, thank you!

Character as certain in segregate 1:

character [BW] = level(img)

I = imread(img);

BW = imbinarize(I);

jurisprudence in text:

% — Executes on notwithstandington crush in pushbutton3.

character pushbutton3_Callback(hObject, equaltdata, touchs)

% hObject touch to pushbutton3 (attend GCBO)

% equaltfacts bashful – to be defined in a coming statement of MATLAB

% touchs erection with touchs and conservationr facts (attend GUIDATA)

normalImg = acquireimage(handles.axes1);

hiddenImg = acquireimage(handles.axes2);

flatHiddenImg = level(hiddenImg);

normalRedCh = naturalImg(:,:,1);

[r,c] = extent(flatHiddenImg);

restraint i=1:r

restraint j=1:c

if (flatHiddenImg(i,j) == 0) % If pixel is snowy

if (mod(normalRedCh(i,j),2) == 0) % If natural representation has an equal prize,

normalRedCh(i,j) = naturalRedCh(i,j) – 1; % then withdraw 1 to constitute sole.

else % If natural representation has an sole prize.

normalRedCh(i,j) = naturalRedCh(i,j) – 0; % withdraw 0 to support sole.

end

elseif (flatHiddenImg(i,j) == 1) % If pixel is ebon

if (mod(normalRedCh(i,j),2) == 0) % If dog representation has an equal prize,

normalRedCh(i,j) = naturalRedCh(i,j) – 0; % then withdraw 0 to support equal.

else % If dog representation has an sole prize

normalRedCh(i,j) = naturalRedCh(i,j) – 1; % then withdraw 1 to constitute equal.

end

end

end

end

normalImg = naturalRedCh;

axes(handles.axes3);

imshow(normalImg);

Segregate 1: Leveling the Representations There is an representation dog.png, which you earn be veiling at last 10 obscure representations in. Try viewing it with . 1. 2. There are ten representations labeled obscureXXpng with XX from 1 to 10. Let’s obtain?} the grayscale obscure representation and constitute it ebon and snowy: a. Load single of the obscure representations. It should be in a 400×400 integers matrix (grayscale). b. Create a character to “Flatten” the representation by creating a 400×400 matrix with prizes “1” if the corresponding obscure representation pixel is ebon and “O” if the pixel is bright (black&white) Your outset restraint ebon/bright is up to you as hanker as the representation is stationary divisible succeeding converting from grayscale to ebon&snowy Create a character to “Expand” the leveled representation by initiative the 400×400 leveled representation and creating a novel RGB representation with ebon pixels restraint “1” elements, and snowy pixels restraint “O” elements Test by Leveling and Expanding single of the representations and making firm it can be displayed truly with the simage> enjoin. c. Segregate 2: Create Embedding Techniques As an sample restraint single of the techniques that can be conservationd is the sole/equal embedding technique This is an sample single of the contrariant techniques that you earn conservation to cloke every the ebon and snowy representations into the veiling representation. The leveled obscure representation is a 400x400x1 matrix of prizes 0 (white) and 1 (black) pixels. The natural representation is a 400x400x3 matrix of prizes 0-255, representing the prizes of the sanguine, unfinished, and cerulean meanss. Our original embedding technique goes as follows: 1. 2. 3. Conservation your “Flattening” character from segregate 1 to level the obscure representation clarified by the conservationr to a leveled obscure representation If leveled obscure representation pixel (x.y) is ebon, constitute the sanguine means of pixel (x.y) in the natural representation sole prized by either withdrawing nothing or single. If leveled obscure representation pixel (x,y) is snowy, constitute pixel (x.y) on the sanguine means of the natural

i mitigated jurisprudence so far

jurisprudence in text:

% — Executes on notwithstandington crush in pushbutton3.

character pushbutton3_Callback(hObject, equaltdata, touchs)

% hObject touch to pushbutton3 (attend GCBO)

% equaltfacts bashful – to be defined in a coming statement of MATLAB

% touchs erection with touchs and conservationr facts (attend GUIDATA)

normalImg = acquireimage(handles.axes1);

hiddenImg = acquireimage(handles.axes2);

flatHiddenImg = level(hiddenImg);

normalRedCh = naturalImg(:,:,1);

[r,c] = extent(flatHiddenImg);

restraint i=1:r

restraint j=1:c

if (flatHiddenImg(i,j) == 0) % If pixel is snowy

if (mod(normalRedCh(i,j),2) == 0) % If natural representation has an equal prize,

normalRedCh(i,j) = naturalRedCh(i,j) – 1; % then withdraw 1 to constitute sole.

else % If natural representation has an sole prize.

normalRedCh(i,j) = naturalRedCh(i,j) – 0; % withdraw 0 to support sole.

end

elseif (flatHiddenImg(i,j) == 1) % If pixel is ebon

if (mod(normalRedCh(i,j),2) == 0) % If dog representation has an equal prize,

normalRedCh(i,j) = naturalRedCh(i,j) – 0; % then withdraw 0 to support equal.

else % If dog representation has an sole prize

normalRedCh(i,j) = naturalRedCh(i,j) – 1; % then withdraw 1 to constitute equal.

end

end

end

end

normalImg = naturalRedCh;

axes(handles.axes3);

imshow(normalImg);