jhlee-visionkalman / accord

Automatically exported from code.google.com/p/accord
0 stars 0 forks source link

Issue with haar transform at orders greater than 1 #101

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I think  your haar wavelet transform might have a defect;

Try transforming an image using it at iteration count greater than 1 (2,3) etc. 
It doesn't output expected result

Fix is;

Needs to be done to inverse transform also

public void FWT(double[,] data, int iterations)
{
    int rows = data.GetLength(0);
    int cols = data.GetLength(1);

    double[] row = new double[cols];
    double[] col = new double[rows];

    for (int k = 0; k < iterations; k++)
    {
        for (int i = 0; i < rows / (k+1); i++)
        {
            for (int j = 0; j < row.Length / (k+1); j++)
                row[j] = data[i, j];

            FWT(row);

            for (int j = 0; j < row.Length / (k+1); j++)
                data[i, j] = row[j];
        }

        for (int j = 0; j < cols / (k+1); j++)
        {
            for (int i = 0; i < col.Length / (k+1); i++)
                col[i] = data[i, j];

            FWT(col);

            for (int i = 0; i < col.Length / (k+1); i++)
                data[i, j] = col[i];
        }
    }
}

Original issue reported on code.google.com by MRD...@gmail.com on 22 Jul 2014 at 12:02

GoogleCodeExporter commented 9 years ago
I've uploaded a image demonstating the isuse; as you can see here

The subimages aren't scaled correctly at all 

Original comment by MRD...@gmail.com on 22 Jul 2014 at 12:16

Attachments:

GoogleCodeExporter commented 9 years ago
Hmm; no. tested my fix and it's not quite right either :/ woops sorry. It's 
close though

Original comment by MRD...@gmail.com on 23 Jul 2014 at 9:04

GoogleCodeExporter commented 9 years ago
Thanks for reporting the issue and for attempting to correct it! Please, may I 
ask if you have an example on what the expected output should be?

Original comment by cesarso...@gmail.com on 5 Aug 2014 at 8:54

GoogleCodeExporter commented 9 years ago
The output of the haar transform of increasing depth should generate a 
hierarchy of sub-images each four times the area of the last.

This is what haar transform at high depth should look like;
http://ksuweb.kennesaw.edu/~jderado/hurricane_files/image036.jpg

The defect with your current code is at higher depth it produces lots of images 
of the same size; rather than a hierarchy of images of increasing resolution; 
which is one of the core properties of the wavelet transform. 

You can see in the attachment included on this defect generated by accord's 
wavelet transform; all the images are the same size. The other wavelet 
transform included with accord (the jpeg one) doesn't suffer from this defect. 
So you can compare the two at high iteration count to observe the flaw.

Cheers
Matt.

Original comment by MRD...@gmail.com on 10 Aug 2014 at 2:04

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Here is a fix I've tested. Attached is file containing new versions of forward 
and inverse transforms. You just need to paste them in and make the methods not 
static.

Original comment by MRD...@gmail.com on 14 Aug 2014 at 9:52

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you very much! The fix will be available in the next release. 

Original comment by cesarso...@gmail.com on 14 Aug 2014 at 6:56

GoogleCodeExporter commented 9 years ago
Available on release 2.13.

Original comment by cesarso...@gmail.com on 19 Aug 2014 at 8:35