フィルターのクリア

how swap the bits at position L&P of A(I,j).?

1 回表示 (過去 30 日間)
Sultan Mehmood
Sultan Mehmood 2018 年 7 月 11 日
コメント済み: Guillaume 2018 年 7 月 20 日
A= imread('camera man.png');
k=1;
for I=1:256;
j=1:256;
end
x=0.3;
p=0.343;
for n=2:65536;
if x(n-1)>=0 & x(n-1)<=p
x(n)=x(n-1)/p;
else
x(n)=(1-x(n-1))/(1-p);
end
end
S=(x*255)+1;
Q=0.2;
p=0.343;
for n=2:65536;
if Q(n-1)>=0 & Q(n-1)<=p
Q(n)=Q(n-1)/p;
else
Q(n)=(1-Q(n-1))/(1-p);
end
end
D=(Q*255)+1;
L= mod(S(k),8)+1;
P=mod(D(k),8)+1;
swap??
  2 件のコメント
KSSV
KSSV 2018 年 7 月 11 日
What you want to swap?
Sultan Mehmood
Sultan Mehmood 2018 年 7 月 11 日
i want to swap the bits of L&P of A(I,j). help plzz

サインインしてコメントする。

採用された回答

Guillaume
Guillaume 2018 年 7 月 11 日
編集済み: Guillaume 2018 年 7 月 18 日
bits = bitget(A(i, j), [L, P]);
A(i, j) = bitset(A(i, j), P, bits(1));
A(i, j) = bitset(A(i, j), L, bits(2));
As an aside, I would strongly recommend that you declare x and Q as:
x = [0.3, zeros(1, 65535)];
Q = [0.2, zeros(1, 65535)];
to avoid the constant reallocations that your code is doing.
  12 件のコメント
Sultan Mehmood
Sultan Mehmood 2018 年 7 月 20 日
what is mean by "bits(1),bits(2)"? because code is running only for first entry.
Guillaume
Guillaume 2018 年 7 月 20 日
bits(1) is the bit that bitget extracted at position L, bits(2) is the bit that bitget extracted at position P.
documentation for bitget
documentation for bitset

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by