Why is there no one to help me?

1 view (last 30 days)
Th star light
Th star light on 15 Sep 2020
Edited: Th star light on 22 Oct 2020
I have a serious problem and No one helps me
please i need help
i am not professional in matlab
this is my code
i only need to replace m & n by the locations in B cell array
please i am tired :(
% Clear the existing workspace
clear all;
% Clear the command window
clc;
input = imread('lena.jpg');
%convert to grayscale
input=rgb2gray(input);
%size of the image
[m,n]=size(input);
%convert to binary
BW = im2bw(input);
%select the largest region in the image
BW2 = bwareafilt(BW,1);
%trace the boundaries of this region with no hole,we can do a hole
B = bwboundaries(BW2,'noholes');
%show the selected boundaries
imshowpair(BW,BW2,'montage')
hold on
a=cell2mat(B);
%show the bounday
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'r', 'LineWidth', 2)
end
%Message to be embedded
message='helloworld';
%Length of the message where each character is 8 bits
len = length(message)* 8;
% Get all the ASCII values of the characters of the message
ascii=uint8(message);
% Convert the decimal values to binary
binmessage=transpose(dec2bin(ascii,8));
% Get all the binary digits in separate row
binmessage=binmessage(:);
% Converting the char array to numeric array
binmessage_num=str2num(binmessage);
% Initialize output as input
output=input;
% Counter for number of embedded bits
counter=1;
for i =1:m
for j = 1:n
% If there are more bits remaining to embed
if(counter <= len)
output(i,j))= bitset(input(i,j)),1,binmessage_num(counter));
% Increment the embed counter
counter = counter+1;
end
end
end
%save both images
imwrite(input, 'C:\Users\OriginalImage.bmp');
imwrite(output,'C:\Users\WatermarkedImage.bmp');
% i want to save the message into the B cell array pixels
  9 Comments
Rik
Rik on 22 Oct 2020
Regarding your emails ("I am sorry, i need to delete this code. I didn't mean to delete it, but it will cause me problems. Please delete it" and "I didn't mean anything. All I needed was help and I didn't mean anything else, please delete it"):
When you posted your question you agreed to the terms of use. Those include the provision that you release your post under the CC-by-sa 3.0 license. That means I have the legal right to republish your post as long as I cite the source and share under a similar license. Repeatedly editing away your question doesn't help you in any way, so please stop doing that. You haven't provided any good reason why your post should be deleted. If you were attempting to cheat, being caught would be a valuable lesson.
If you actually do have a good reason to want your post deleted, please explain so in a comment. Us volunteers (and the Mathworks staff) are not immune to good reasons.
Th star light
Th star light on 22 Oct 2020
Edited: Th star light on 22 Oct 2020
I am sorry, this code belongs to me, I was wrong to put it to public
I am sorry again for doing that
I did not know that and made a mistake, and I will not repeat it again

Sign in to comment.

Accepted Answer

Steven Lord
Steven Lord on 15 Sep 2020
Count your parentheses. If you start a counter at 0, add 1 to the counter every time you see a (, and subtract 1 from the counter every time you see a ), the counter value can show you certain problems.
  1. If the counter value is not 0 at the end of the statement, you don't have the same number of opening and closing parentheses.
  2. If the counter value every becomes negative, you have too many closing parentheses for the number of opening parentheses in the statement before the point where the counter value becomes negative.
output(i,j))= bitset(input(i,j)),1,binmessage_num(counter));
0 1 0X
The X indicates the counter becoming negative. If we remove that parenthesis to correct that problem we can check further:
output(i,j)= bitset(input(i,j)),1,binmessage_num(counter));
0 1 0 1 2 10 1 0X
Here the problem is not the ) where the counter becomes negative, it's earlier in the line. You ended the bitset call with the ) immediately before ",1" but then you tried to continue the bitset call by passing in a second and third input argument. Removing that parenthesis:
output(i,j)= bitset(input(i,j),1,binmessage_num(counter));
0 1 0 1 2 1 2 10
Code Analyzer can tell you if you have mismatched parentheses (look for the little red lines in the right margin of the Editor and the red, orange, or green square at the top of that margin) though it may not be able to tell you exactly how to resolve the problem. I had to read and understand the line to know that the final parenthesis was not the cause of the second problem but that it had occurred earlier. Making those changes to the line made your code syntactically valid (no red Code Analyzer messages) though it can't prove your code is correct.

More Answers (0)

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!