i want to restore the original binary image S by xor the two shares R1,R2

2 Ansichten (letzte 30 Tage)
S = imread('binary.png');
C = imread('text input.png');
[m, n] = size(S);
no = 2;
beta = 1;
R1 = zeros(m, n);
R2 = zeros(m, n);
for i = 1:m
for j = 1:n
d = rand;
if d < beta
"function T = algo2(S(i, j), no)";
R1(i, j) = T(1);
R2(i, j) = T(2);
else
if mod(n*C(i, j), no) == 0
R1(i, j) = C(i, j);
R2(i, j) = C(i, j);
else
f = randi([1 no]);
for k = 1:n
if k == f
R1(i, j) = 1 - C(i, j);
R2(i, j) = 1 - C(i, j);
elseif k < f
R1(i, j) = C(i, j);
R2(i, j) = C(i, j);
else
R1(i, j) = C(i, j);
R2(i, j) = C(i, j);
end
end
end
end
end
end
S_restored = bitxor(R1, R2);
imshow(S_restored);
this is the code for restore the original bianry image,in this the the line "function T = algo2(S(i, j), no)"; calls the another code algo2 for the 2 pixel shares...but the resulting image is full of black.i tried so many times to rectify it.help to get rid of the issue
code for algo2:
function T = algo2(S, n)
S=imread('text input.png');
meven=[0 0 0;
0 1 1;
1 0 1;
1 1 0];
modd=[0 0 1;
0 1 0;
1 0 0;
1 1 1];
no=1;
y =zeros(size(S));
R=zeros(size(S));
l=zeros(size(S));
for i = 1:size(S,1)
for j = 1:size(S,2)
if (S(i, j) == 0)
r=rand([no,2^no-1]);
disp(r)
ro=round(r*(size(meven,1)-1))+1;
disp(ro)
R(i,j)=meven(ro,1);
l(i,j)=meven(ro,2);
else
r=rand([no,2^no-1]);
disp(r)
ro = round(r*(size(modd,1)-1))+1;
disp(ro)
R(i,j)=modd(ro,1);
l(i,j)=modd(ro,2);
end
end
end
y(i,j)=S(i,j);
  2 Kommentare
Image Analyst
Image Analyst am 28 Mär. 2023
No idea, because you forgot to attach your two input images. You didn't even attach screenshots, so I gave up at that point.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
Walter Roberson
Walter Roberson am 28 Mär. 2023
"function T = algo2(S(i, j), no)";
That line just constructs a 1 x 1 string array in which the first element contains ['f' 'u' 'n' 'c' 't' 'i' 'o' 'n' ' ' 'T' ] and so on.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Encryption / Cryptography finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by