Hello Again!!
This article is beyond from the programming. FYI as a programmer you should have a knowledge about these things. If not you will ended up with a mess.
It's RLE
What is it?
Run Length Encoding is a very simple form of loosless data compression in which runs of data are stored as a single data value and count, rather than as the original run.
Understood?
I bet you wont !!
Let me go it with my way right after this article you will a have sufficient knowledge about RLE for sure.
Let's Dive in !
Let's try an encoding image drawn using three colors on a 5x5 grid.
First we will use simple method
We have assigned a letter to each of the colors, Y for Yellow, G for Green, and B for Blue.
As a result of transforming the rows into Ys,Gs nad Bs one line at a time starting from the upper left, we were able to encode the figure into a line of 25 letters.
Next, using run legth encoding on the image, let's try expressing it in less than 25 letters.
Run Length Encoding is a method of encoding that makes a code and the number of times it repeats into a set.
For example we can express the first "YYYY" part as "Y4",which is two characters shorter.
The same operation repeats, completing the run length encoding.
As a result, the code was five characters shorter,compressed to 20.If it's known that the image has 5 squares per row, the original image can be extracted from the code. These operations are called "compression" and "decompression".Run Length Encoding is well suited for some types of data, but not so well suited for others.
If we look closely at the encoded line, we see that, as a whole, the number of characters has decreased.....
But the parts that don't have the same color consecutively actually end up increasing in character count after being run length encoded.
For example , if we apply run length encoding to data like this, which is low in consecutive characters....
the data doubles to 50 characters
Conversely, when we apply run length encoding to data with continuity like this..
The encoded data is 10 characters. Compared to the original 25, it has been compressed a considerable amount.
As you can see, depending on the taarget data, there arae times when the compression is effective, and times when it isn't. Therefore, a variety of strategies are necessary, such as only using run length encoding for data with more than a fixed number of consecutive characters.
As an example,let's consider using run length encoding on a monochrome fax.
Is we simply assign a W for white and B for black to express each square when sending this image, the result will be 25 characters.To keep the amount of traffic down,let's try compressing the data with run length encoding.
The result gives us 26 characters, an increase of one, so using run length encoding here was meaningless.However, a monochrome image uses only two colors,black and white.Therefore, if we reach the end of a run of white squares, the next square will always be black.It seems that we can restore the image from the code even without the letters W and B.
The W and B were omitted,resulting in a total of 13 characters, a compression about half the size.
However, we need to establish a rule so that we know the first number in the code refers to a consecutive number of white squares.With such a rule, we can correctly restore the image from the code.
So, how should we go about encoding an image like the following?
In contrast to the previous image,the first square is black,not white
For the time being, we have tried encoding the image using the same method as before.
The first number in the code, 6 refers to the consecutive number of black squares....but that doesnt follow our rule that states "the first number in the code refers to a consecutive run of white squares".
If we restore the image from the current code, it will result in an image with black and white inverted.
So that we absolutely follow our :the first number in the code refers to a consecutive number of white squares" rule, a 0 was added to the beginning of the code.
This tells us that there are 0 white squares, in other words no white squares, at the beginning of the image.By adding the 0 to the beginning of the code, the nuber of letters in the code increased by one,but we were able to compress the data while following our established rule.
In general, you can say that run length encoding is geared toward compressing image data more than text,which lacks consecutively repeating data.
What is desired is a strategy that exhibits superior compression results in either case.
I hope you all gathered what is RLE and how it works
-ThilanJR10-
This article is beyond from the programming. FYI as a programmer you should have a knowledge about these things. If not you will ended up with a mess.
It's RLE
What is it?
Run Length Encoding is a very simple form of loosless data compression in which runs of data are stored as a single data value and count, rather than as the original run.
Understood?
I bet you wont !!
Let me go it with my way right after this article you will a have sufficient knowledge about RLE for sure.
Let's Dive in !
Let's try an encoding image drawn using three colors on a 5x5 grid.
First we will use simple method
We have assigned a letter to each of the colors, Y for Yellow, G for Green, and B for Blue.
As a result of transforming the rows into Ys,Gs nad Bs one line at a time starting from the upper left, we were able to encode the figure into a line of 25 letters.
Next, using run legth encoding on the image, let's try expressing it in less than 25 letters.
Run Length Encoding is a method of encoding that makes a code and the number of times it repeats into a set.
For example we can express the first "YYYY" part as "Y4",which is two characters shorter.
The same operation repeats, completing the run length encoding.
As a result, the code was five characters shorter,compressed to 20.If it's known that the image has 5 squares per row, the original image can be extracted from the code. These operations are called "compression" and "decompression".Run Length Encoding is well suited for some types of data, but not so well suited for others.
If we look closely at the encoded line, we see that, as a whole, the number of characters has decreased.....
But the parts that don't have the same color consecutively actually end up increasing in character count after being run length encoded.
For example , if we apply run length encoding to data like this, which is low in consecutive characters....
the data doubles to 50 characters
Conversely, when we apply run length encoding to data with continuity like this..
The encoded data is 10 characters. Compared to the original 25, it has been compressed a considerable amount.
As you can see, depending on the taarget data, there arae times when the compression is effective, and times when it isn't. Therefore, a variety of strategies are necessary, such as only using run length encoding for data with more than a fixed number of consecutive characters.
As an example,let's consider using run length encoding on a monochrome fax.
Is we simply assign a W for white and B for black to express each square when sending this image, the result will be 25 characters.To keep the amount of traffic down,let's try compressing the data with run length encoding.
The result gives us 26 characters, an increase of one, so using run length encoding here was meaningless.However, a monochrome image uses only two colors,black and white.Therefore, if we reach the end of a run of white squares, the next square will always be black.It seems that we can restore the image from the code even without the letters W and B.
The W and B were omitted,resulting in a total of 13 characters, a compression about half the size.
However, we need to establish a rule so that we know the first number in the code refers to a consecutive number of white squares.With such a rule, we can correctly restore the image from the code.
So, how should we go about encoding an image like the following?
In contrast to the previous image,the first square is black,not white
For the time being, we have tried encoding the image using the same method as before.
The first number in the code, 6 refers to the consecutive number of black squares....but that doesnt follow our rule that states "the first number in the code refers to a consecutive run of white squares".
If we restore the image from the current code, it will result in an image with black and white inverted.
So that we absolutely follow our :the first number in the code refers to a consecutive number of white squares" rule, a 0 was added to the beginning of the code.
This tells us that there are 0 white squares, in other words no white squares, at the beginning of the image.By adding the 0 to the beginning of the code, the nuber of letters in the code increased by one,but we were able to compress the data while following our established rule.
In general, you can say that run length encoding is geared toward compressing image data more than text,which lacks consecutively repeating data.
What is desired is a strategy that exhibits superior compression results in either case.
I hope you all gathered what is RLE and how it works
-ThilanJR10-
nice work
ReplyDeleteWow Thilan!!
ReplyDelete