how to add a matrix with the pixel of an image

1 次查看(过去 30 天)
Hi I want to add a matrix with the pixels of an image.image size is 512 512 and matrix size is 2*2.
I=imread('lina512.bmp');
key=[8 5;5 3];
k=de2bi(key);
red=I(:,:,1);
I1=de2bi(red(:));
I dont know how to do bitwise xor
  5 个评论
sadiqa ilyas
sadiqa ilyas 2019-9-7
k(binary )of key matrix is xored with the binary of the pixels.
I=imread('lina512.bmp');
key=[8 5;5 3];
k=de2bi(key);
red=I(:,:,1);
I1=de2bi(red(:));
[x y]=size(I1);
zor=zeros(size(I1));
for i=1:x
zor(i,:)=xor(I1(i),k)% gives error.
end
zor;
Can u plz tell what is the mistake
Walter Roberson
Walter Roberson 2019-9-7
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by