Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

A generic image decoder - specification design

8 views
Skip to first unread message

Gautier write-only

unread,
May 1, 2010, 1:03:18 PM5/1/10
to
Hello,
I've just started a generic image decoder package project.
You can read the specification here:
http://gen-img-dec.svn.sourceforge.net/viewvc/gen-img-dec/gid.ads?revision=1&view=markup
Before going on with the implementation, I would be glad to get any
comment on it.
From typos, naming, to possible performance considerations related to
generics, or image formats, or what else ?...
TIA
______________________________________________________________
Gautier's Ada programming -- http://gautiersblog.blogspot.com/
NB: For a direct answer, e-mail address on the following web site:
http://www.fechtenafz.ethz.ch/wm_email.htm

Gautier write-only

unread,
May 1, 2010, 4:30:23 PM5/1/10
to
Here is already a tiny update:

http://gen-img-dec.svn.sf.net/viewvc/gen-img-dec/gid.ads?view=markup&pathrev=2

I've discovered the possibility of an Inline pragma to a procedure
listed in a generic formal part. At least GNAT and ObjectAda don't
protest on that, so probably it makes some sense...

G.

Andre

unread,
May 2, 2010, 5:19:52 AM5/2/10
to
Gautier,

The first question which comes up in mind is: where do you want to use
it for?
Is it an initial step for your Ada based browser?

The 2nd question is more basic, are you write the load image functions
in Ada or use bindings to existing libraries (like the JPEG one)?

Basically all pixel based images are a block of memory. The one which
are 8 bit based use normally a Palette (like GIF and 8-bit BMP). The
full color versions (JPEG, 24-bit BMP) use 3 or 4 byte per pixel (4th
one is in general the alpha channel) in a memory map. So that can easily
be modeled.
If it is for a browser, you can forget about the 1-, 2- and 4-bit images.

So how will be your real image data be modeled?
Do you plan to just use a 24-bit with alpha channel format and convert
lower grade images (like GIF) into this format?
Or do you want to represent the different image types also in you data
model?

just some feedback,
Andr�

rasikasr...@gmail.com

unread,
May 2, 2010, 6:48:12 AM5/2/10
to
On May 2, 5:19 am, Andre <avsa...@hotmail.com> wrote:
> Gautier,
>
> The first question which comes up in mind is: where do you want to use
> it for?
> Is it an initial step for your Ada based browser?
>
> The 2nd question is more basic, are you write the load image functions
> in Ada or use bindings to existing libraries (like the JPEG one)?
>
> Basically all pixel based images are a block of memory. The one which
> are 8 bit based use normally a Palette (like GIF and 8-bit BMP). The
> full color versions (JPEG, 24-bit BMP) use 3 or 4 byte per pixel (4th
> one is in general the alpha channel) in a memory map. So that can easily
> be modeled.
> If it is for a browser, you can forget about the 1-, 2- and 4-bit images.
>
> So how will be your real image data be modeled?
> Do you plan to just use a 24-bit with alpha channel format and convert
> lower grade images (like GIF) into this format?
> Or do you want to represent the different image types also in you data
> model?
>
> just some feedback,
> André

>
> On 5/1/2010 22:30, Gautier write-only wrote:
>
> > Here is already a tiny update:
>
> >http://gen-img-dec.svn.sf.net/viewvc/gen-img-dec/gid.ads?view=markup&...

>
> > I've discovered the possibility of an Inline pragma to a procedure
> > listed in a generic formal part. At least GNAT and ObjectAda don't
> > protest on that, so probably it makes some sense...
>
> > G.
>
>

If it helps plan, I have an almost complete thin OpenCV binding at
projectlets.sourceforge.net

IMHO if the intent is to support Image Processing algorithms, then
OpenCV or itk would be the libraries to model after and possibly
support to leverage.

Cheers, srini

brian

unread,
May 2, 2010, 7:45:21 AM5/2/10
to
On May 2, 1:03 am, Gautier write-only <gautier_niou...@hotmail.com>
wrote:

> Hello,
> I've just started a generic image decoder package project.
> You can read the specification here:http://gen-img-dec.svn.sourceforge.net/viewvc/gen-img-dec/gid.ads?rev...

> Before going on with the implementation, I would be glad to get any
> comment on it.
> From typos, naming, to possible performance considerations related to
> generics, or image formats, or what else ?...

Have you thought about supporting the FITS (http://
fits.gsfc.nasa.gov/) format?

-Brian

Gautier write-only

unread,
May 2, 2010, 11:09:35 AM5/2/10
to
On May 2, 11:19 am, Andre <avsa...@hotmail.com> wrote:

> The first question which comes up in mind is: where do you want to use
> it for?
> Is it an initial step for your Ada based browser?

Many things, from image manipulation without display, loading of
textures for GL (there it would replace the "input" part of the GL.IO
provided with GLOBE_3D), display into a rectangle of a GUI system and
an in-memory cache (good guess: for a browser :-) ),...

> The 2nd question is more basic, are you write the load image functions
> in Ada or use bindings to existing libraries (like the JPEG one)?

The whole would be in Ada. The code already exists for GIF, BMP, TGA,
in different places. The decompression for PNG can be taken from
UnZip.Decompress. JPEG is a bit trickier.
There are "Pascal" sources that could be used, perhaps.

> Basically all pixel based images are a block of memory. The one which
> are 8 bit based use normally a Palette (like GIF and 8-bit BMP). The
> full color versions (JPEG, 24-bit BMP) use 3 or 4 byte per pixel (4th
> one is in general the alpha channel) in a memory map. So that can easily
> be modeled.
> If it is for a browser, you can forget about the 1-, 2- and 4-bit images.
>
> So how will be your real image data be modeled?
> Do you plan to just use a 24-bit with alpha channel format and convert
> lower grade images (like GIF) into this format?
> Or do you want to represent the different image types also in you data
> model?

The color model is 24-bit. Palettes will be decoded.
The transparent pixels in GIF will have alpha=Opacity_range'First and
the others will have Opacity_range'Last.
All the rest (basically, the choice of the memory model, and what to
do with transparency) is left to the user.
For instance GL.IO will keep its model: a data buffer, which is sent
to GL via Insert_into_GL.
But decoded pixels might be even directly sent to a "screen" or a GUI
object if it makes sense (e.g when decoding an interlaced PNG to a
visible image on a Web page), without any Ada storage of the image.

> just some feedback,
> André

Thanks for it!
Gautier

Gautier write-only

unread,
May 2, 2010, 11:15:25 AM5/2/10
to
On May 2, 1:45 pm, brian <brian.cat...@gmail.com> wrote:

> Have you thought about supporting the FITS (http://fits.gsfc.nasa.gov/) format?

Until now, not, but I've of course added it to the [wish] list of
formats.
Thanks!

Gautier

Dmitry A. Kazakov

unread,
May 2, 2010, 11:21:39 AM5/2/10
to
On Sun, 2 May 2010 08:09:35 -0700 (PDT), Gautier write-only wrote:

> On May 2, 11:19�am, Andre <avsa...@hotmail.com> wrote:
>
>> The first question which comes up in mind is: where do you want to use
>> it for? Is it an initial step for your Ada based browser?
>
> Many things, from image manipulation without display, loading of
> textures for GL (there it would replace the "input" part of the GL.IO
> provided with GLOBE_3D), display into a rectangle of a GUI system and
> an in-memory cache (good guess: for a browser :-) ),...

Do you plan image processing stuff? I have somewhere half-written pyramid
and region-growing segmenting in Ada.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Gautier write-only

unread,
May 2, 2010, 3:21:23 PM5/2/10
to
On 2 mai, 17:21, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:

> Do you plan image processing stuff?

Not yet - maybe one day...


> I have somewhere half-written pyramid and region-growing segmenting in Ada.

Sounds good!
G.

Gautier write-only

unread,
May 2, 2010, 3:24:13 PM5/2/10
to
On 2 mai, 13:45, brian <brian.cat...@gmail.com> wrote:

> Have you thought about supporting the FITS (http://fits.gsfc.nasa.gov/) format?

Do you know what maximum color depth there is with FITS ?
I guess it might be more than 255 per fundamental color, but I got
lost in the docs.
Perhaps I should let this 255 boundary as a generic parameter as well.

Gautier

Brian Drummond

unread,
May 2, 2010, 6:07:25 PM5/2/10
to

If it's not just for viewers, but also for photography and graphic arts,
it would be well worth supporting 16-bit per channel colour depths.
(Some scanners are 12-bit but that is often padded to 16 anyway.)

- Brian

tmo...@acm.org

unread,
May 2, 2010, 7:01:12 PM5/2/10
to
> >I guess it might be more than 255 per fundamental color, but I got
> >lost in the docs.
> >Perhaps I should let this 255 boundary as a generic parameter as well.
>
> If it's not just for viewers, but also for photography and graphic arts,
> it would be well worth supporting 16-bit per channel colour depths.

Generic handling at the pixel level will surely be slower than direct
coding that knows what it's operating on, and that will be an issue
if there's any significant pixel level processing. CLAW uses tags to
distinguish images with different memory layouts, so image processing
dispatches to the correct code for the image at hand.
Picture : Claw.Bitmaps.Root_DIBitmap_Type'Class
:= Claw.Bitmaps.Root_DIBitmap_Type'Class'Input(Stream);
The different images have arrays of, e.g.,
for RGB555_Color_Type use record
Blue at 0 range 0 .. 4;
Green at 0 range 5 .. 9;
Red at 0 range 10 .. 14;
Alpha at 0 range 15 .. 15;
end record;
for Triple_Color_Type use record
Blue at 0 range 0 .. 7;
Green at 1 range 0 .. 7;
Red at 2 range 0 .. 7;
end record;

But is your package aimed more at processing images, or at doing IO on
the myriad file formats of images? And how about video?

Gautier write-only

unread,
May 3, 2010, 8:18:05 AM5/3/10
to
On May 3, 1:01 am, tmo...@acm.org wrote:

> Generic handling at the pixel level will surely be slower than direct
> coding that knows what it's operating on, and that will be an issue
> if there's any significant pixel level processing.

Not necessarily if the generics are properly inlined (perhaps you are
thinking of shared generics).
The range of primary colors is now a generic parameter too. So there
will be tests like "if Color_Range'Last=255 then..." which will be
resolved at compile-time by smart compilers.

[...]


> But is your package aimed more at processing images, or at doing IO on
> the myriad file formats of images?

Only decoding images of various formats, that's all!
> And how about video?
This is not excluded. Probably I'll add an out parameter,
time_of_next_frame, to the Load_image_contents procedure.
_________________________________________________________
Gautier's Ada programming -- http://sf.net/users/gdemont/

Gautier write-only

unread,
May 5, 2010, 5:07:20 PM5/5/10
to
...here (only via svn checkout):
http://sf.net/projects/gen-img-dec/develop
As a prototype, I've done the .bmp format (1/4/8 bits, uncompressed)
so far.
A demo/tool for GID is the To_BMP procedure.
Enjoy!
Gautier

Stephen Sangwine

unread,
May 24, 2010, 4:51:30 PM5/24/10
to
On 2010-05-01 18:03:18 +0100, Gautier write-only
<gautier...@hotmail.com> said:

Interesting idea. What you are proposing looks to me like a sort
of binding to various image libraries, in that you provide basic
image reading/writing to a variety of formats. Of course, you
can't handle all the special features of each image format, but
for an application that just needs to read or write the pixels
and a few other basics like palettes, alpha etc, the approach
would be useful. I can speak from experience of developing PNG_IO
to say that handling any non-trivial format is not a small task.
BMP is pretty easy - TIFF is probably the hardest to handle. In
both PNG and TIFF the pixel data is stored in disparate pieces
within the file - not as a single block of pixel data. In the
case of PNG the compression runs across these blocks, not within
each block. What this means is that code for handling the pixel
data can't easily be common to different types of image file.

You have available an Ada package for PNG already in PNG_IO.
I've thought about GIF as a student project now that the
compression is no longer subject to patent protection, but no
work has been done on it yet.

Steve Sangwine

Gautier write-only

unread,
May 24, 2010, 5:42:16 PM5/24/10
to
Thanks for the feedback.
The project is really restricted to decoding images of the broadest
spectrum of formats and do whatever the user wants to do with the
pixels: store into a buffer (and process, save, or save that buffer),
or display them directly in a GUI object, or whatever else...
The current state so far is:
* BMP is done, except RLE compression and some unusual bit depths
* GIF is complete (including animated pictures)
* PNG is covering all but transparent formats; there is a nasty glitch
with the decompression, so it works on some pictures and on some,
not...
up to now I was able to have a common source for all formats;
sure, I should have a closer look to PNG_IO...
* TGA is on a good way to be complete

You can have a look via a svn checkout:
svn co https://gen-img-dec.svn.sf.net/svnroot/gen-img-dec gid
and with gnatmake -P gid.gpr
It builds ./test/to_bmp on your platform.
Note: there is a "Fast" mode in the gid.gpr project file!
Gautier

0 new messages