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개)

카테고리

Help CenterFile Exchange에서 Functional Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by