How to use VPA (variable precision arithmetic) in calculating HH band via dwt on an image?

1 次查看(过去 30 天)
I have the following code:
img = imread('cameraman.tif');
[LL,LH,HL,HH] = dwt2(img, 'db1');
I have to calculate HH band using vpa (32 digits), instead of double precision.
Plz help in this regard.

采纳的回答

Stephan
Stephan 2019-12-9
编辑:Stephan 2019-12-9
You can not do this. dwt2 accepts only double as input and outputs double. vpa works on symbolic variables and returns a symbolic variable:
>> vpa(pi)
ans =
3.1415926535897932384626433832795
>> whos ans
Name Size Bytes Class Attributes
ans 1x1 8 sym
So you will either get an error if you try to pass a symbolic variable to dwt2 or you will have to cast it to double, which also does not help you. What you can do is show 32 digits of the result calculated as double:
>> a = pi/2
a =
1.5708
>> sprintf('%.32g',a)
ans =
'1.5707963267948965579989817342721'
>> whos
Name Size Bytes Class Attributes
a 1x1 8 double
ans 1x33 66 char
Maybe this helps.

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by