Problem with Haar wavelet transform

1 view (last 30 days)
Tran Tuan Anh
Tran Tuan Anh on 13 May 2014
Answered: Hari on 24 Feb 2025
Hi every ones
I have a problem when I code matlab program and really need your help
I have a binary image (only 0 and 1) I use haar wavelet transform by matlab code : [LL,LH,HL,HH] =dwt2( f, 'haar'); I also have four subimage
LL : has maximun is 2 and min is 0 ( in this we have 0 - 0.5 - 1 - 1.5 - 2)
HL and LH and HH: have max is 1 and min is -1 ( in this we have -1 - (-0.5) - 0 - 0.5 - 1)
But now, because this is a binary image so I want our result just belong to 0 and 1. May be we can use low passfilter is OR logical and high passfilter is XOR.
But I don't know how to explain this and code, Please help me.
Thank you so much

Answers (1)

Hari
Hari on 24 Feb 2025
Hi Tran,
I understand that you are working with a binary image and have applied the Haar wavelet transform using MATLAB, resulting in subimages with values outside the binary range. You want to convert these subimages back to binary using logical operations.
I assume you want to apply logical operations to the subimages to maintain binary values (0 and 1) based on logical operations like OR and XOR.
In order to convert the Haar wavelet subimages to binary values, you can follow the below steps:
Apply Logical OR to LL:
Use the “OR” operation on the LL subimage to convert values to binary. This can be done by checking if the value is greater than 0.
LL_binary = LL > 0; % Converts any positive value to 1
Apply Logical XOR to LH, HL, HH:
Use the “XOR” operation on the LH, HL, and HH subimages to convert them to binary. This can be done by checking if the absolute value is greater than 0.
LH_binary = abs(LH) > 0; % Converts any non-zero value to 1
HL_binary = abs(HL) > 0;
HH_binary = abs(HH) > 0;
Combine the Binary Subimages:
Combine the binary subimages if necessary, or use them individually based on your application requirements. This step depends on how you intend to use the binary results.
Example Code:
Here is an example of how you can apply these operations:
% Assume LL, LH, HL, HH are obtained from dwt2
LL_binary = LL > 0;
LH_binary = abs(LH) > 0;
HL_binary = abs(HL) > 0;
HH_binary = abs(HH) > 0;
Validate the Results:
Check the results to ensure they meet your expectations by visualizing or analyzing the binary subimages.
Refer to the documentation of “dwt2” function to know more about its properties and usage:
Hope this helps!

Categories

Find more on Discrete Multiresolution Analysis in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!