Questions tagged [run-length-encoding]

Run-length encoding (RLE) is a very simple form of data compression in which runs of data (that is, sequences in which the same data value occurs in many consecutive data elements) are stored as a single data value and count, rather than as the original run.

Run-length encoding is most useful on data that contains many such runs: for example, simple graphic images such as icons, line drawings, and animations. It is not useful with files that don't have many runs as it could greatly increase the file size.

254 questions
2
votes
5 answers

Task from the interview. How we would solve it?

Convert String in this way let initialString = "atttbcdddd" // result must be like this "at3bcd4" But repetition must be more than 2. For example, if we have "aa" the result will be "aa", but if we have "aaa", the result will be "a3" One more…
Stanislav Marynych
  • 188
  • 1
  • 1
  • 14
2
votes
3 answers

Min and max of NA sequences

I have a data frame in which the column foo contains running sequences of NA values. For example: > test id foo time 1 1 2018-11-19 00:00:48 2 1 2018-11-19 00:10:51 3 1 2018-11-19 00:21:15 4 1
iskandarblue
  • 7,208
  • 15
  • 60
  • 130
2
votes
3 answers

how to count persistance in days for characters

Let's say we have this data: type <- paste("type", c(1,1,1,2,3,1,2,2,3,3,3,3,1,1)) dates <- seq(as.Date("2000/1/1"), by = "days", length.out = length(type)) mydataframe <- data.frame(type, dates) I saw in other posts that rle might do the job but…
Andrei Niță
  • 517
  • 1
  • 3
  • 14
2
votes
1 answer

Count consecutive values in groups with condition with dplyr and rle

My question is very similar to the one posed below, however I want to add an additional command to return only cases when a sequence has more than 2 consecutive values. How do I count the number of consecutive "success" (i.e. 1 in $consec) when a…
2
votes
2 answers

Best lossless compression technique for serializing a foot pressure map

I am working with pressure-sensing of human feet, and I need to transmit frames in realtime over serial. The typical frame is like below, consisting of a flat background and blobs of non-flat data: The speed of transmission is currently a…
heltonbiker
  • 26,657
  • 28
  • 137
  • 252
2
votes
2 answers

Decoding RLE in CUDA efficiently

I need to decode an RLE in CUDA and I have been trying to think about the most efficient way of expanding the RLE into a list with all my values. So Say my values are 2, 3, 4 and my runs are 3, 3 , 1 I want to expand that to 2, 2, 2, 3, 3, 3, 4. At…
flips
  • 308
  • 1
  • 2
  • 16
2
votes
4 answers

In Place Run Length Encoding Algorithm

I encountered an interview question: Given a input String: aaaaabcddddee, convert it to a5b1c1d4e2. One extra constraint is, this needs to be done in-place, means no extra space(array) should be used. It is guaranteed that the encoded string will…
geeky
  • 135
  • 2
  • 10
2
votes
3 answers

How to increment some of elements in an array by specific values in MATLAB

Suppose we have an array A = zeros([1,10]); We have several indexes with possible duplicate say: indSeq = [1,1,2,3,4,4,4]; How can we increase A(i) by the number of i in the index sequence i.e. A(1) = 2, A(2) = 1, A(3) = 1, A(4) = 3? The code…
2
votes
0 answers

Write the length of the word after using the Run-Length-Compression

I want to write the length of the word w which has the following form: w=a^nb^mc^pd^q with n,m,p,q >=2 after using the Run-Length-Compression. Also if w = a^2b^3c^4d^5 I can write w with the Run-Length-Compression as a0b1c00d01. The first binary…
Mr Asker
  • 2,300
  • 11
  • 31
  • 56
2
votes
1 answer

Is the compressed size of all bitmap indices for a particular column at most proportional to the size of your table?

I was reading Daniel Lemire's post The Mythical Bitmap Index (http://lemire.me/blog/archives/2008/08/20/the-mythical-bitmap-index/) and in the post he says the compressed size of a bitmap index is at most proportional to the size of your table!…
user2108462
  • 855
  • 7
  • 23
2
votes
2 answers

Run-Length encoding image compression in Java

Okay so i've got a University assignment where I need to compress an image using both Run-length encoding and huffman encoding. I'm focusing on the Run-Length encoding atm since I don't think i'm going to have time to implement the huffman. What I…
2
votes
5 answers

count successive occurrences of number in Prolog

Hello I am trying to make a program in Prolog that given a list it counts the occurrences of each successive element in the list as follows: count(1,[1,1,1,2,2,2,3,1,1],0,X) the result would be X=[ [1,3],[2,3],[3,1][1,2] ] aka each sublist is…
JmRag
  • 1,443
  • 7
  • 19
  • 56
2
votes
1 answer

Indices of constant consecutive values in a matrix, and number of constant values

I have a matrix with constant consecutive values randomly distributed throughout the matrix. I want the indices of the consecutive values, and further, I want a matrix of the same size as the original matrix, where the number of consecutive values…
mr. cooper
  • 810
  • 1
  • 9
  • 15
2
votes
3 answers

Repeat elements of vector

I have a value vector A containing elements i, for example: A = [0.1 0.2 0.3 0.4 0.5]; and say r = [5 2 3 2 1]; Now I want to create a new vector Anew containing r(i) repetitions of the values i in A, such that the first r(1)=5 items in Anew have…
Fraukje
  • 673
  • 3
  • 20
2
votes
1 answer

Combining lossless data compression algorithms

I was wondering about how far we can take lossless data compression; I wasn't able to find an online simulator of lossless algorithms to perform some empiric testing. I could just make one on my own, but unluckily I don't have enough time in this…