i have to do bitxor on image pixel wise

1 visualización (últimos 30 días)
juveria fatima
juveria fatima el 5 de Sept. de 2018
Abierta de nuevo: juveria fatima el 10 de Sept. de 2018
i have lena image as
rgb_image=imread('lena.png');
size of rgb_image is 512*512*3
rgb_image_1(1,1)
ans =
225
>> rgb_image_1(1,2)
ans =
224
bitxor(rgb_image_1(1,1),rgb_image_1(1,2))
ans =
1
first pixel value is 255 which bitxored with second pixel value 224 and the results is 1
similarly i will do for 3rd pixel and 4th pixel i.e
rgb_image_1(1,3)
ans =
224
>> rgb_image_1(1,4)
ans =
223
>> bitxor(rgb_image_1(1,3),rgb_image_1(1,4))
ans =
63
1) i have to do bitxor for complete image to form a new bitxored image
2) i have to get back the lena image by doing the reverse bitxor
  1 comentario
Guillaume
Guillaume el 5 de Sept. de 2018
Editada: Guillaume el 5 de Sept. de 2018
You still need to clarify what the desired result is, as I asked in your other question.
Since you get one value by xor'in two pixels. Is the result half as big as the original?
As I said, give us an example of the desired output. E.g. for the matrix:
img = [208 33 162 72
231 233 25 140]
what is the exact desired output?
Side note: in matlab, the 2nd pixel, rgb_image(2), is rgb_image(2, 1), not rgb_image(1, 2).

Iniciar sesión para comentar.

Respuestas (1)

Guillaume
Guillaume el 5 de Sept. de 2018
From your latest comment, I'm unclear whether or not you've solved your problem. The code you've posted will always error when processing the last column and last row (since i+1 and j+1 go past the size of the image). In any case, a loop is not needed and the error-free, loop-free version of that code is:
rgb_image_1 = imread('lena.png');
new_image = bitxor(rgb_image_1(1:end-1, :, :), rgb_image_1(2:end, :, :));
recon_image = bitxor(rgb_image_1(:, 1:end-1, :), rgb_image_1(:, 2:end, :));
Note that necessarily, new_image will have one less column than the origignal image and recon_image one less row.
  9 comentarios
Walter Roberson
Walter Roberson el 10 de Sept. de 2018
Do the bitwise xor again and put the results to the right of a copy of the first column.
Guillaume
Guillaume el 10 de Sept. de 2018
@juveria fatima, as this looks like homework you should put more effort in understanding with your encryption/decryption algorithm. You should have been able to work out yourself that you needed to keep around at least one column/row of the original image if you want to be able to reverse the encryption.
By necessity, a decryption algorithm can't use the original image for decrypting. Otherwise, there'd be no point in the encryption process in the first place. Now, look at the decryption code that you wrote. The problem should be obvious for yout to correct on your own.
You probably should think a bit more about what parts of the image you xor together. So far, you've been given code that does exactly what you ask. However, you'll notice that you calculate new_image and never do anything with it.

Iniciar sesión para comentar.

Categorías

Más información sobre C4ISR en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by