在MATLAB编程中如何分别对两个数组分别执行二进制XOR运算?

时间:2019-05-01 05:30:40

标签: matlab image-processing bit xor

我试图对具有二进制值的两个数组的每个位分别执行XOR操作,但是xor(array1,array2)给出错误的结果。如何正确地做到这一点?

clc;
clear;
image = imread('stego.png');
password = 'ComplexPassword';
password_binary = reshape(dec2bin(password, 8)', 1, []);

%value of first pixel of image of different channel
temp_pixel_red = dec2bin(image(1, 1, 1), 8);
temp_pixel_green = dec2bin(image(1, 1, 2), 8);
temp_pixel_blue = dec2bin(image(1, 1, 3), 8);

MSB_red = temp_pixel_red(1);
MSB_green = temp_pixel_green(1);
MSB_blue = temp_pixel_blue(1);

%create an array of MSB value of each channel
MSB = [MSB_red,MSB_green,MSB_blue];

%create another array of first three bit of password.
key = [password_binary(1),password_binary(2),password_binary(3),];

C = xor(MSB, key);
disp(C);

在这里MSB = 000key = 010 它给出了result = 000,但我希望有result = 010

0 个答案:

没有答案