Text Compression and Decompression using BWT

729 views Asked by At

I want to ask that can we combine the BWT MTF and Huffman Algorithms to get higher compression rate in java? what will be the process? Error In Wriring of MTF file?

public class MTF{
    static File f=new File("MTF.txt");
public static File encode(String msg, String symTable)throws Exception{
            if(!f.exists())
                f.createNewFile();
    StringBuilder s = new StringBuilder(symTable);
    for(char c : msg.toCharArray()){
        int idx = s.indexOf("" + c);
                    FileWriter writer = new FileWriter(f); 
                    writer.write(idx+" "); 
                    System.out.print(idx+" ");
                    writer.flush();
                    writer.close();
        s = s.deleteCharAt(idx).insert(0, c);
    }
            System.out.println("MTF done");
    return f;
}
1

There are 1 answers

0
Mindaugas Bernatavičius On BEST ANSWER

It is quite easy to test this hypothesis, the process would be:

  • take a representative set of strings (strings that your program will be dealing with in "real world");
  • encode with BWT MTF (implementations are numerous on the internet);
  • compress with Huffman;

In general: Applying MTF should improve compresability, as, for example mentioned here: http://michael.dipperstein.com/bwt/

BWT is useful because it converts the data into a format that is generally more compressible by run length encoders and statistical encoders with order greater than 0. By additionally applying move-to-front coding, the data will be in a format which is generally more compressible by even zero order statistical encoders such as traditional implementations of Huffman coding or arithmetic coding.