i have to do bitxor on image pixel wise
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
Guillaume
2018 年 9 月 5 日
編集済み: Guillaume
2018 年 9 月 5 日
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).
回答 (1 件)
Guillaume
2018 年 9 月 5 日
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 件のコメント
Walter Roberson
2018 年 9 月 10 日
Do the bitwise xor again and put the results to the right of a copy of the first column.
Guillaume
2018 年 9 月 10 日
@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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!