Closed Thread
Results 1 to 2 of 2

Thread: Run Length Encoding problem

  1. #1
    TriKri Guest

    Run Length Encoding problem

    Hello!

    I have to solve a run length coding problem in matlab, compressing a vector containing integer numbers between 0 and 255, to a new vector with numbers between 0 and 255 using the following method:

    * A number 0 ≤ n ≤ 127 in the encoded data means that the following n+1 numbers will be direct copies from the original data
    * A number 129 ≤ n ≤ 255 in the encoded data means that the next number has existed 257-n times in a row in the original data
    * The number 128 means that the sequence is over.

    For example, the following vector: [0 1 2 9 9 9 4 5 6 7]
    can be encoded to: [2 0 1 2 254 9 3 4 5 6 7 128]
    or to: [9 0 1 2 9 9 9 4 5 6 7 128]
    of which each encoding is equally good, since they are equally long (but longer than the original though).


    Now I tried to find an algorithm which will always provide an optimal solution to this problem, using dynamic programming, but I realized it was too long since I last solved a similar problem. I just can't figure out how to come up with such an algorithm, but I suspect one could do it with dynamic programming. I would really appreciate if someone could help me out here!

    Thanks in advance!

  2. CODECALL Circuit advertisement

     
  3. #2
    Join Date
    Jan 2008
    Posts
    1,725
    Blog Entries
    4
    Rep Power
    29

    Re: Run Length Encoding problem

    I don't know matlab so I have no clue how to do it in that program.

    However if you were to do it in an actual programming language such as c++, a couple of if statements and perhaps a for loop would do the trick. Of course, any language would do the trick the same way.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Lithuanian language encoding
    By thatsme in forum PHP Development
    Replies: 14
    Last Post: 07-27-2011, 06:56 AM
  2. Content Encoding Error
    By An Alien in forum Website Design
    Replies: 4
    Last Post: 01-29-2011, 01:07 PM
  3. Replies: 5
    Last Post: 09-16-2009, 02:29 PM
  4. Looking for a simple encoding/encryption method
    By Gezeiten in forum PHP Development
    Replies: 7
    Last Post: 08-05-2008, 05:18 AM
  5. C, text file and it's encoding
    By denarced in forum C and C++
    Replies: 11
    Last Post: 07-31-2008, 11:32 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts