Jump to content

Recommended Posts

Posted

Does anybody know of an image compression algorithm similar to

<script>
imagewidth = 300;

colors =
{
(0,0,0,0)[20,30,40,60,200](255,255,255,0)[120,270,140,160,300]

};

document.write(colors.rgb000000000000);
</script>

where instead of writing rgba (a,b,c,d) a thousand times like in png to donate the color instead all the pixels to be given a specific color are written by their pixel position index in the image only storing colors actually used??

Posted (edited)

Did you try PHP image generation?

http://php.net/manual/en/image.examples-png.php

JavaScript could download file from some URL,

but instead of "image.png", there is PHP script instead, generating image.

To have it with .png extension, there is needed to modify Apache and/or PHP configuration file, which file types are processed by PHP daemon.

This way user does not even have to know script is run to make image.

(not really required, one can have "generate.php" script output PNG, as browser recognize image by header, the first line in script in the above link)

Edited by Sensei
Posted

Does anybody know of an image compression algorithm similar to

 

where instead of writing rgba (a,b,c,d) a thousand times like in png to donate the color instead all the pixels to be given a specific color are written by their pixel position index in the image only storing colors actually used??

 

Interesting idea. I haven't come across it before. Sounds a little bit like texture mapping.

 

I'm not sure what the advantage is; it doesn't obviously take any less space. You still have to have value for every pixel, just that it will be the coordinates, rather than the pixel values (consider the ,limiting case where every pixel is black, for example: you still have to list the coordinates of every pixel.) However, combine it with run-length encoding and there might be an advantage.

 

Although it makes operations on the image (e.g. filtering) more complex.

Posted (edited)

Quite interesting, i can give you a few options. Or the way i would do it in order to compress the image, i hope that we can lose abit of quality.

I would convert all colors from argb to rgb, in other words we would now instead of having (m*4)^n, we would get (m*3)^n.

 

Now we have a few options, there is 2 ways of compressing, by the biggest or by the smallest, this also how the OS(Operaty System) storges data, in a little soft version.

 

Lets start from the most efficent way(save space). You analize an image and you see that there is a pattern of colors like red, yellow, red,green, red, yellow, red, blue.

So what you do now is the following, you grab in this partner and you try to find other pattern, in the pattern you got. So now instead you will get this following patterns:

red, yellow;

red,green;

red,blue;

Whit this, our gold is to reduce the ammount of "samples", less samples means more space saved.

Dont forget you need to have a map in order to know where each samples start and a good computer also, to find the patterns.

 

The other way is doing the same, but backwards.

 

In other words you identifie the small samples 1st and you try to reach the big patterns.

Edited by Yvtq8k3n
Posted
coordinates, rather than the pixel values (consider the ,limiting case where every pixel is black, for example: you still have to list the coordinates of every pixel

 

 

Consider the case where you might want to store locations. For instance the same method can be applied to 3 dimensional objects. Perhaps a method could be added like color the next 200 pixels black. Old image compression used the idea of a color table where you chose from a predefined list of colors like 256 colors which has advantages in that the file could be smaller but it also limited the availability of colors.

  • 2 weeks later...
Posted

... Perhaps a method could be added like color the next 200 pixels black. ...

That's "run length encoding". Take a look at RLE files.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.