显示 更早的评论
Hello I want to do the "bitxor" operation as shown in below code. But since bitxor takes only 2 arguments the following code gives ERROR. Please suggest a solution. Mail me at lokesh_jolly05@yahoo.co.in
L(3*(i-1)+1)=mod(bitxor(B1(3*(i-1)+1),uint64(mod((abs(X(i))-floor(abs(X(i))))*10^14,256)),256));
3 个评论
Jan
2011-12-26
Please post the error message.
I receive the following error for bitxor:
"??? Error using ==> bitxor
Inputs must be unsigned integers of the same class or scalar
doubles."
Please suggest solution.
How to do that?or should I partition the above formulae?
B1 is image, rest are the parameters going in a for loop.
采纳的回答
Walter Roberson
2011-12-26
You have a bracket misplaced.
L(3*(i-1)+1)=mod(bitxor(B1(3*(i-1)+1),uint64(mod((abs(X(i))-floor(abs(X(i))))*10^14,256))),256);
Notice the ')' after 256 was moved to the end of the previous argument.
15 个评论
Thanks Walter.
But now I receive the following error for bitxor:
"??? Error using ==> bitxor
Inputs must be unsigned integers of the same class or scalar
doubles."
Please suggest solution
What datatype is B1 ? The uint64() around the second argument is forcing that argument to be unsigned 64 bit integers, so if B1 is not also unsigned 64 bit integers, you have a problem.
mod((abs(X(i))-floor(abs(X(i))))*10^14,256) appears likely to be floating point number in the range 0 to (256 minus epsilon) . Converted to a 64 bit unsigned integer is going to have the effect of rounding that value, leading to results in the range 0 to 256 inclusive. Is that what you want, that you would normally be working with the bottom 8 bits only but that on occasion you would instead be working with the 9th bit only (256 exactly) ?
B1 is image, rest are the parameters going in a for loop.
B1 is a grayscale image after some opearions.
While X(i) parameters are based on equations involving Numerical methods.
What does class(B1) indicate? If it is a grayscale image such as you indicate, it is almost certainly not unsigned 64 bit integer. It might plausibly be unsigned 8 bit integer, or unsigned 16 bit integer, or double precision.
What is your intention with the code? What is it that you want that section of code to do?
THE CODE is used to just to shuffle the image.
The B1 is a grayscale image & to protect the image three parameters X,Y & Z are calculated. Then the BitXOR is done to get final image.
The code looks as below:
L=zeros(M,M);
for i=1:(M^2/3-1)
L(3*(i-1)+1)=mod(bitxor(B1(3*(i-1)+1),uint64(mod((abs(X(i))-floor(abs(X(i))))*10^14,256))),256);
L(3*(i-1)+2)=mod(bitxor(B1(3*(i-1)+2),uint64(mod((abs(Y(i))-floor(abs(Y(i))))*10^14,256))),256);
L(3*(i-1)+3)=mod(bitxor(B1(3*(i-1)+3),uint64(mod((abs(Z(i))-floor(abs(Z(i))))*10^14,256))),256);
end;
where M is size of B1 image. What can be B1 image-unsigned 8, 16 or double --How to know that?
Any other solution or suggestion?
Thanks in advance!!
class(B1)
will tell you what the datatype is.
it is unit 8,but now i receive ERROR:
??? Attempted to access Y(201); index out of bounds because
numel(Y)=200.
Also I would like to know that is the "i" loop termination parameters ok-->M^2/3-1
I pointed out above that in some cases, it could end up being the 9th bit you are attempting to modify -- unless there is something in the way that X and Y and Z are calculated that prevents that. Altering the 9th bit of 8 is going to be trouble...
You have not shown us any code involving Y so we cannot advise you as to what the problem is for it.
for i=1:(M)
%L(3*(i-1)+1)= mod(bitxor(B(3*(i-1)+1),unit64(mod(abs(X(i)-floor(abs(X(i)),256)*10^14)),256);
L(3*(i-1)+1)=mod(bitxor(B1(3*(i-1)+1),uint8(mod((abs(X(i))-floor(abs(X(i))))*10^14,256))),256);
L(3*(i-1)+2)=mod(bitxor(B1(3*(i-1)+2),uint8(mod((abs(Y(i))-floor(abs(Y(i))))*10^14,256))),256);
L(3*(i-1)+3)=mod(bitxor(B1(3*(i-1)+3),uint8(mod((abs(Z(i))-floor(abs(Z(i))))*10^14,256))),256);
end;
Reference:A Chaotic Image Encryption
Katherine Struss,2009
How about showing us the code that computes X and the code that computes Y... if, that is, you are still hoping for feedback from us as to why Y is the length it is.
The Mathematica code constructs and uses X, Y, and Z up to position index length^2/3, which is array location number length^2/3+1 (because Mathematica uses 0 based indexing). Your MATLAB code constructs X, Y, and Z up to position 200 (fixed number), but then tries to use up to M^2/3-1.
I thought that in the past I had seen that Mathematica was able to generate MATLAB code from Mathematica code. If that is correct, it would probably be better to use that conversion than to convert it yourself -- or to at least use the automated conversion for comparison.
I know that such conversion is possible.Do you have nay idea about it,i am unable to get any conversion S/W or toolbox?
http://library.wolfram.com/infocenter/MathSource/577/
how to use the Mathemtica to matlab Expression converter as i have Matlab 2010Ra & Mathematica v 8.
I need to convert the following expressions into matlab:
B=Flatten[B];
L=partition[L,length];
Any solution
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
