MATLAB Answers

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

2 views (last 30 days)
Abdul Gaffar
Abdul Gaffar on 9 Dec 2019
Edited: Stephan on 9 Dec 2019
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.

  0 Comments

Sign in to comment.

Accepted Answer

Stephan
Stephan on 9 Dec 2019
Edited: Stephan on 9 Dec 2019
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 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.