MATLAB: First, I want to divide binary image into 8 by 8 block.Second I want to perform rowise logical AND(1st AND 2nd,2nd AND 3rd …..so on ) and from that results i want to do XOR.Please help me with matlab code.

suppose i have 8 rows ,i need to do logical AND for first and second row,then second and third …..then neglect same vectors using unique,from that remaining vectors i want to do overall XOR.

Best Answer

ur = unique(block(1:end-1) | block(2:end), 'rows');
uxor = mod(sum(ur,1),2);
You might notice that I did not use explicit xor() here. When you have a vector of binary values, xor is 0 if the sum of the vector is even, and xor is 1 if the sum of the vector is odd. (For xor, 0 do not change the result, but every 1 toggles the result, so even numbers of 1's toggle the result back to 0 and odd numbers of 1's leave it at 1)