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

5 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.

Accepted Answer

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 =
>> 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 =
>> sprintf('%.32g',a)
ans =
>> whos
Name Size Bytes Class Attributes
a 1x1 8 double
ans 1x33 66 char
Maybe this helps.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!