Sign in to follow this  
Hindol

Wavelet (Haar 2-tap) Transformation of an Image (Source and DLL)

Recommended Posts

Did this just for fun. But it's extremely slow. I re-wrote it so it is very fast now. Thanks to the inbuilt multithreaded processing capabilities.

Definition of Haar 2-tap transformation can be found here at Wikipedia.

An excellent interactive demonstration of Haar transformation (written in Java by Tom Gibara) can be found here - Haar Wavelet Filtering.

My ultimate aim is to implement some face detection algorithm here as a plugin, :). Just for fun!

Edit: This is not just another filter or effect you can apply to your image. Test it only if you know what Haar transform is.

Paint.NET - Haar Transform.zip

Example:-

Before:

23jiq0z.png

After:

bdr1g4.png

Edited by Hindol

Share this post


Link to post
Share on other sites

the final image is smaller than the original diveded by 4. in fact i got four tiles. I cannot obtain any transform with jpg but with png files, not tested further

im using PDN 3.5.8

Is there any twist to achieve the work?

GBE

Share this post


Link to post
Share on other sites

the final image is smaller than the original diveded by 4. in fact i got four tiles. I cannot obtain any transform with jpg but with png files, not tested further

im using PDN 3.5.8

Is there any twist to achieve the work?

GBE

Actually the final image is not smaller. It is divided into four sub-bands.

Top-left = Average of four pixels

Top-right = Vertical details ie. it shows whether there are any vertical edges / lines in the image

Bottom-left = Horizontal details (same but detects horizontal lines)

Bottom-right = Diagonal details

One interesting fact is that the original image can be fully recovered from the transformed image (with some minimal quantization errors).

I just tested it. It does not work with images other than jpg.

This is my very first plugin that I put together in some 2 hours (most of the time spent figuring how CodeLab works). I still do not understand how exactly the multi-threading works. Because all constraints on X seem to work correctly but Y constraints are a guessing game.

void Render(Surface dst, Surface src, Rectangle rect) <= What do I do with the rect parameter? I figured it had to do something with the threads. Each rect represents just a piece of an image? And multiple threads work with multiple rects at the same time? I am clueless.

Share this post


Link to post
Share on other sites

yes the image is divided, with jpg top left seams to be the original image with no transform, with png top left seams to be the image mixed with transformations layers,

i've tested on an icon for png, since i've my bank stocked on another harddisk

If i catch your meaning the image will be transformed applying 3 filters, each one on a layer, and the result is supposed to be a mix with the original and the transform layers

but actually the result is tiles with each layer side by side.

GBE

Share this post


Link to post
Share on other sites

yes the image is divided, with jpg top left seams to be the original image with no transform, with png top left seams to be the image mixed with transformations layers,

i've tested on an icon for png, since i've my bank stocked on another harddisk

If i catch your meaning the image will be transformed applying 3 filters, each one on a layer, and the result is supposed to be a mix with the original and the transform layers

but actually the result is tiles with each layer side by side.

GBE

Actually no, I am happy with my results for JPEG images. This is not a filter similar to Gaussian blur, InkSketch etc. And I guess my plugin is of no use to anyone. To understand what I am trying to do, go to Tom Gibara's page and set Iterations = 1, Reduction = 0, Quantization = 0. That is what I am trying to do. Look how the image is Haar transformed and then inverse Haar transformed to retrieve the original image again. This technique is widely used in image compression algorithms like JPEG2000 and other formats. (JPEG used DCT or discrete cosine transform but the newer JPEG2000 uses DWT or discrete wavelet transform, and Haar transform is one type of DWT).

Share this post


Link to post
Share on other sites

Hi Hindol!

You've said  that Tom Gibara's example is very good for java, but i wasn't able to use it.

Do you have an code example of Tom Gibara's lib or know other libraries that i can apply haar ou daubechies on images.

If you do, could you please give me a code example since the reading to the writting.

Thank you anyways!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this