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
4
votes
4 answers

Find longest run of consecutive zeros for each user in dataframe

I'm looking to find the max run of consecutive zeros in a DataFrame with the result grouped by user. I'm interested in running the RLE on usage. sample input: user--day--usage…
4
votes
5 answers

Using rle to eliminate first and last sequences

I am trying to solve a problem with R using rle() (or another relevant function) but am not sure where to start. The problem is as follows - foo, bar, and baz and qux can be in one of three positions - A, B, or C. Their first position will always…
iskandarblue
  • 7,208
  • 15
  • 60
  • 130
4
votes
2 answers

Align with word boundary in RLE bitmap: contradiction in Microsoft documentation

Microsoft's Bitmap Compression documentation, specifically the description of BI_RLE8 (8-bit indexed color using run-length encoding compression), includes the following description of absolute mode: In absolute mode, the first byte is zero and the…
4
votes
3 answers

Get length of runs of missing values in vector

What's a clever (i.e., not a loop) way to get the length of each spell of missing values in a vector? My ideal output is a vector that is the same length, in which each missing value is replaced by the length of the spell of missing values of which…
daanoo
  • 771
  • 5
  • 18
4
votes
4 answers

Create counter of consecutive runs of a certain value

I have data where consecutive runs of zero are separated by runs of non-zero values. I want to create a counter for the runs of zero in the column 'SOG'. For the first sequence of 0 in SOG, set the counter in column Stops to 1. For the second run of…
Manuel Frias
  • 311
  • 1
  • 4
  • 10
4
votes
1 answer

Substract last N values from rle() object

The following function is used to create a path overview for the following dataset: tc <- textConnection(' path touchpoint time abc A 1 abc A 2 abc B 3 …
Max van der Heijden
  • 1,095
  • 1
  • 8
  • 16
4
votes
1 answer

Run Length Encoding - SIMD

I am trying to optimise the run length coding. I was thinking of implementing it in SIMD. I spent a few hours working on the algo but couldn't proceed much. Is it worth giving it a shot? I am working on Neon. Thanks.
Rugger
  • 373
  • 3
  • 10
4
votes
6 answers

What would be a good (de)compression routine for this scenario

I need a FAST decompression routine optimized for restricted resource environment like embedded systems on binary (hex data) that has following characteristics: Data is 8bit (byte) oriented (data bus is 8 bits wide). Byte values do NOT range…
PoorLuzer
  • 24,466
  • 7
  • 31
  • 35
4
votes
4 answers

Run Length Encoding in Matlab

I'm very new with MatLab, I have Run Length Encoding code but it seems to not work, can you help me? I have this input : ChainCode = 11012321170701000700000700766666666666665555555544443344444333221322222322 and I want make it into RLE output :…
user1146895
  • 51
  • 1
  • 1
  • 5
3
votes
5 answers

How do i make the program print specific letters in this specific format i give to it?

so i need to code a program which, for example if given the input 3[a]2[b], prints "aaabb" or when given 3[ab]2[c],prints "abababcc"(basicly prints that amount of that letter in the given order). i tried to use a for loop to iterate the first given…
krox
  • 39
  • 1
3
votes
6 answers

JavaScript algo: decompress a compressed string

I wanted to write a function that takes a compressed string and outs the decompressed string. A compressed string like a2b2c3 and the decompress string is aabbccc More examples would be `a` -> `a` `ab12` -> `abbbbbbbbbbbb` `a3b2a2` -> `aaabbaa I…
Joji
  • 4,703
  • 7
  • 41
  • 86
3
votes
6 answers

Implementing run-length encoding

I've written a program to perform run length encoding. In typical scenario if the text is AAAAAABBCDEEEEGGHJ run length encoding will make it A6B2C1D1E4G2H1J1 but it was adding extra 1 for each non repeating character. Since i'm compressing BMP…
Anirudh Goel
3
votes
3 answers

Create run-length ID while allowing for gaps of certain length in runs

(I initially posted a question here, but it didn't fully cover my issue) I have a data frame with a 'date' column and a measure of precipitation (rainfall): date precip 1 1 0.0 2 2 0.0 3 3 12.4 4 4 10.2 5 5 0.0 6 6 …
Robin Kohrs
  • 655
  • 7
  • 17
3
votes
3 answers

Conditional Subsetting of a Nested List

I have a nested list where ach sub list has two lists. A simplified output of this list is below: nested.list <- list(`1` = structure(list(lengths = c(325L, 18L, 1L, 7L, 1L, 10L, 1L, 35L, 1L, 1L, 152L, 1L, 1L, 37L, 1L, 33L, 1L, 15L, 2L, 1L, 47L,…
MCG
  • 35
  • 4
3
votes
2 answers

cumsum is.na with rle ignoring consectives NA's

simple problem. Lets say I have the following data: library(tidyverse) df <- data.frame(group = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2), variable = c(NA, "a", NA, "b", "c", NA, NA, NA, NA, "a", NA, "c", NA, NA,…
user63230
  • 4,095
  • 21
  • 43
1 2
3
16 17