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
3
votes
1 answer

Extract a bitmap from a PostScript (CIP3) file

I've asked a similar question some months ago, on the following link: Creating a code to decompress byte-oriented RLE image And I've also read this question (was closer to mine): Extract a bitmap from PostScript I am dealing with CIP3 files, which…
paboobhzx
  • 109
  • 10
3
votes
3 answers

How to split a dataframe of values and use rle on the chunks?

I am trying to divide up (not necessarily into even chunks, bc the real data may vary) a single column of integers called scores (.csv file) and then count the consecutive values (of x chosen value, e.g. 1) in each divided portion or the mean length…
3
votes
1 answer

Using java-streams for data compression

I have been trying to find an example of how to use java-streams as compressor. I still have not figured out how to do this and I have neither found anyone else that done it. So that I would like to do is to count occurrences, of something, in the…
3
votes
1 answer

Run-Length Encoding assumptions

When implementing the Run-length encoding (RLE), can I assume that the Runs are going to be shorter than one byte? So there will not be a situation where there is a run like this WWWBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB... Where there…
3
votes
2 answers

R - Finding max number of consecutive values by key

I have a dataset of messages sent to users, some have succeeded and some have failed: > df.messages <- data.frame(date = c("2018-01-01 12:00","2018-01-01 12:00","2018-01-01 12:00","2018-01-02 12:00","2018-01-02 12:00","2018-01-02 12:00","2018-01-03…
Chris
  • 313
  • 1
  • 11
3
votes
2 answers

Replace sequence of identical values of length > 2

I have a sensor that measures a variable and when there is no connection it returns always the last value seen instead of NA. So in my vector I would like to replace these identical values by an imptuted value (for example with…
agenis
  • 8,069
  • 5
  • 53
  • 102
3
votes
3 answers

Can I get the total length of an rle object without using inverse?

Let us say I have a Rle like so, of length 10: b = rle(c("H", "T", "T", "H", "H", "H", "H", "H", "T", "H")) How can I get the length of this object without using inverse.rle? length(inverse.rle(b)) # 10 I have some sparse Rles representing…
The Unfun Cat
  • 29,987
  • 31
  • 114
  • 156
3
votes
4 answers

Generate an array with specific duplicate elements in MATLAB

I have one array, for example B = [2,5,7], and also have a number C = 10, where C is always larger than or equal to the largest number in B. and I want to generate an array A according to B and C. In this specific example, I have A = [1, 2, 2, 2,…
ezheng
  • 103
  • 5
3
votes
2 answers

Ruby Run-length encoding fail

I'm a newbie training at codewars and I can't find where my mistake is in this RLE problem , here are the instructions: Your task is to write such a run-length encoding. For a given string, return a list (or array) of pairs (or arrays) [ (i1, s1),…
3
votes
2 answers

Calculate a variable based on length of run of specific value in R code

I have a data set like this, dat <- data.frame(d1=c(0,1,0,1,0), d2=c(0,1,1,1,0),d3=c(1,0,1,1,0), d4=c(1,0,0,0,0),d5=c(1,1,1,0,0)) dat d1 d2 d3 d4 d5 1 0 0 1 1 1 2 1 1 0 0 1 3 0 1 1 0 1 4 1 1 1 0 0 5 0 0 0 0 …
Rudro88
  • 231
  • 3
  • 15
3
votes
1 answer

Trying to write a simple compiler in java (I am using notepad++)

My question is how would I write a simple compiler ,that is like the compilers used in fax machines, that would convert something like aaaavvvvvddddddddddd to 4a5vBd. Also, I get to "Assume" that any string entered will not contain uppercase letters…
Mr.Trips
  • 39
  • 3
3
votes
1 answer

Run Length Encoding an Image

I am writing an Run Length Image Encoder for an assignment. My code works very well for binary and 8 bit images but when I want to encode an 4 bit image it doesn't work correctly. I am using Ubuntu 13.10, Python 3.3.4 and Pillow. Executing following…
3
votes
3 answers

Pixel chains from run length encoding

I've been banging my head for a long time on this one I am doing imaging. So far I've binarized my images, meaning that from a grayscale image, every pixel under a certain value are dropped. This gives me only some regions out of the original image…
Eric
  • 19,525
  • 19
  • 84
  • 147
3
votes
1 answer

Reading and Compressing a picture with RLE

Currently I am learning python and I'd like to get a little bit more into Data Compression. So I decided to try to code Run-Length Encoding(RLE). From what I've read it can be useful when you try to compress pictures. I would like to know what would…
Doc
  • 345
  • 4
  • 17
3
votes
5 answers

Compression Program in C

I want to compress a series of characters. For example if i type Input : FFFFFBBBBBBBCCBBBAABBGGGGGSSS (27 x 8 bits = 216 bits) Output: F5B7C2B3A2B2G5S3 (14 x 8 bits = 112bits) So far this is what i have, i can count the number of Characters in the…
Delandilon
  • 31
  • 1
  • 1
  • 4