One thing for sure, there's no need for slow and unnecessary de2bi conversion in order to perform bitwise xor. But if what you want to do is bitwise xor instead of an addition (two completely different things) then it's not clear what should be xor'ed with what.
Your image is probably 8 bit so your I1 is probably something by 8. Your key values are at most 8 so only need 4 bits and there are 4 of them so k is 4x4. zor is the same size as I1 so it is something by 8. You have a for loop over the number of rows in I1 so I1(i) will be a scalar representing one bit (not a row of bits). Your xor that scalar with the 4x4 k so you get a 4x4 result. You try to store that 4x4 result in zor(i, :) which is 1x8.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
5 Comments
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/479280-how-to-add-a-matrix-with-the-pixel-of-an-image#comment_743136
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/479280-how-to-add-a-matrix-with-the-pixel-of-an-image#comment_743136
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/479280-how-to-add-a-matrix-with-the-pixel-of-an-image#comment_743167
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/479280-how-to-add-a-matrix-with-the-pixel-of-an-image#comment_743167
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/479280-how-to-add-a-matrix-with-the-pixel-of-an-image#comment_743174
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/479280-how-to-add-a-matrix-with-the-pixel-of-an-image#comment_743174
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/479280-how-to-add-a-matrix-with-the-pixel-of-an-image#comment_743180
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/479280-how-to-add-a-matrix-with-the-pixel-of-an-image#comment_743180
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/479280-how-to-add-a-matrix-with-the-pixel-of-an-image#comment_743251
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/479280-how-to-add-a-matrix-with-the-pixel-of-an-image#comment_743251
Sign in to comment.