Monday, September 29, 2008

Fractal Image Compression

Recently I was very interested for fractal image compression. Read about it on Wikipedia (fractals, fractals compression). I start surfing web to look for images compressed with this algorithm and the first image i found was on the www.steckles.com. Author was made a comparison between three image compression algorithms Vector Quantization, Fractal Compression and JPEG. His conclusion was too easy: "Stick with Jpeg, unless you really like bad image quality and long waits". The only thing I don't like in those article was that the examples of images were without evidence of the image size. Here you can find my own dilettantish test :).

Uncompressed image (RAW format 256x256 pix, 8 bit, 64 kb)

JPEG compressed image (JPEG format 256x256 pix, 8 bit, 23 kb)
it was the maximum compression I was obtain of JPEG format

Fractal compressed image (Fractal compression 256x256 pix, 8 bit, 7 kb)

Conclusion:

Yes, fractal compression is very slowly today, especially for big images, but it is easy to see the potential. You can see by sight, a difference in image size and it's quality. I think it is having prospects.  In this little experiment I was compress source image in 9 times. Wikipedia says it will be possible to compress image up to 1000 times without catastrophical loss in quality. Will see :).

Monday, September 22, 2008

PostgreSql Oid to Name (oid2name)

Function gets name of object by oid and its catalog name:
CREATE OR REPLACE FUNCTION oid2name(
  id integer,
  catalog varchar
)
RETURNS varchar AS
$$
SELECT cast(c.name as varchar)
FROM 
  (
  select
    CASE $2
    WHEN 'pg_class' THEN
      (select t.relname as name
       from pg_catalog.pg_class t
       WHERE oid = $1)
    WHEN 'pg_constraint' THEN
       (select t.conname as name
        from pg_catalog.pg_constraint t
        WHERE oid = $1)
    WHEN 'pg_type' THEN
       (select t.typname as name
        from pg_catalog.pg_type t
        WHERE oid = $1)
    WHEN 'pg_conversion' THEN
       (select t.conname as name
        from pg_catalog.pg_conversion t
        WHERE oid = $1) 
    WHEN 'pg_proc' THEN
       (select t.proname as name
        from pg_catalog.pg_proc t
        WHERE oid = $1) 
    WHEN 'pg_rewrite' THEN
       (select t.rulename as name
        from pg_catalog.pg_rewrite t
        WHERE oid = $1)
    WHEN 'pg_trigger' THEN
       (select t.tgname as name
        from pg_catalog.pg_trigger t
        WHERE oid = $1)
    WHEN 'pg_language' THEN
      (select t.lanname as name
       from pg_catalog.pg_language t
       WHERE oid = $1)
    WHEN 'pg_namespace' THEN
      (select t.nspname as name
       from pg_catalog.pg_namespace t  
       WHERE oid = $1)
    END as name
  ) as c
$$
LANGUAGE 'sql'
IMMUTABLE
CALLED ON NULL INPUT
SECURITY INVOKER;

Wednesday, April 16, 2008

First message in blog...

Welcome to my blog.
This is a test message.