Image to array

Hi,
that will be addition of new methods to TImage/TASImage class
not changing signatures.

The major changes are

  • TImage is not abstract class. All pure virtual methods are now
    simply virtual.
  • TImage is derived from TVirtualPS

Sure, it will be backward compatible.

Regards. Valeriy

[quote=“valeri”]Hi,
Actually it is the answer on the original question: is there an easy way to read for example BMP image into the array.

The below function do the job. This function is in principle a part of class, we use for storage and processing images. It could be posted if have general interst. Of cause root is not the best tool for image processing, but sometimes it could be convenient for the small samples.

VT
[/quote]

I’ve just spent some time writing a library of functions to deal with PNG files. But using libpng [libpng.org/pub/png/] to deal with the real dirty stuff at the lowest level.

I’m just about to start collating it into a proper C++ class so maybe that will be useful if I ever convince myself that I’ve got the memory deallocation sorted…

-chris

Hi chris,
current development version of ROOT provides
(via ASImage, which has built-in libpng) support
for png image reading/writing for all ROOT platforms/compilers.
Do not spend your time for re-inventing the wheel :imp:
ASImage is “super” library, e.g. much more sophisticated
than Qt’s QImage, better than ImageMagick etc.
ROOT team works closely with ASImage author (Sasha Vasko),
e.g. currently I’m adding vector graphics to it.
There are many tasks in ASImage development were
we (ROOT team and Sasha Vasko) need supporters/volunteers.

Regards. Valeriy

It is a new desing curve :unamused:
The derivation the TImage class from TPostscript does indicate the class in question is becoming the print driver rather the image processing class.

This I can not understand. TImage should remain TImage. If one needs the printer driver based on TImage that should be done separately. As Rene teach us do not put different fruits in one basket.

Hi Valeri,
TImage remains image processing class
with vector graphics capability (I’m “stealing” a lot of from Xserver code).
In fact, now, it more or less corresponds to Qt4.0 QPainter
doc.trolltech.com/4.0/qt4-arthur.html

Regards. Valeriy

This is what I did say:

QPainter
doc.trolltech.com/4.0/qpainter.html

is not a QImage.

doc.trolltech.com/4.0/qimage.html

Thanks Valeriy.

I’ll look into it.

-chris

Hi Valeri,
I do not see any contradictions.
We has an image processing class which
allows to read images into memory (btw, RLE compressed array),
dispaly this memory in the canvas, write this memory into images.
To satisfy user requests we added
vector graphics to it i.e. draw lines, polygons etc.
over memory compressed array. Thats addon correponds
to addition QPainter methods to QImage class.

As a result one can manipulate,save ROOT canvas graphics into
GIF,PNG etc formats in batch mode (“gifbatching”).
BTW, this is very important for Carrot development
carrot.cern.ch/

There are many other interesting directions opened up …
Just few of them:

  1. improving canvas graphics performance.
    It’s possible to rewrite canvas graphics as painting over TImage
    and flushing TImage onto screen.
    That will allow to improve canvas graphics quality by adding anti-aliasing
    for lines drawing

  2. browser (IE, mozilla …) ROOT plugin development, which will
    interact with Carrot website (server side macros)

  3. ROOT GUI (TGxxx) widgets skinning, flicker free painting (double-buffering)

Regards. Valeriy

Hi Valeri,
thanks for you points and discussion.
It’s really not good to derive TImage from TVirtualPS
because TVirtualPS is “too canvas oriented”, e.g. everything
in pad coordinates … even despite of the fact that TImage is
a part of graf library (which seems to be also not correct).
The better solution is keep TImage derived from Tnamed as it’s
right now and create a new class derived from TVirtualPS(say “TImagePS”).
I will correct my code, which is not yet in CVS.

Regards. Valeriy

[quote=“Valeriy Onuchin”]Hi chris,
current development version of ROOT provides
(via ASImage, which has built-in libpng) support
for png image reading/writing for all ROOT platforms/compilers.
Do not spend your time for re-inventing the wheel :imp:
ASImage is “super” library, e.g. much more sophisticated
than Qt’s QImage, better than ImageMagick etc.
ROOT team works closely with ASImage author (Sasha Vasko),
e.g. currently I’m adding vector graphics to it.
There are many tasks in ASImage development were
we (ROOT team and Sasha Vasko) need supporters/volunteers.

Regards. Valeriy[/quote]

Dear Valeriy O.

Please don’t mix the different topics and points to avoid the mess (as Rene Brun teaches us).

  1. Nobody dicuss the qulity of ASImage library

  2. QImage does what QImage C++ class should. QImage is NOT a C++ LIBRARY. QImage is a part of Qt library. So comparing one single class of the big library vs another entire library one risks arriving to a wrong conlusion and mislead the ROOT users.

QImage porivides a tramsparent and convinient interface to the various pixel file format.

Likely ROOT does need that. I think ROOT needs some image processing classes also. However it is a SEPARATE :exclamation: issue.

QImage is not an image processing class.
The original issue was , “how to access ther pixel” file and the proper soltuion is QImnage. It does fit the task. The image processing is expected to be provided by the user code in this oarticular case.

Since I am not aware about the concrete image processing needs I personally hesistate :blush: to provide any advice which library is “super” one.

STOP SPAM :imp:


Hi Valeri Fine,
let’s spamming go on! :smiley:

Providing rendering on PS/PDF or on images is general movement
in recent X Window System development, check
keithp.com/~keithp/talks/xarch_o … 2004-html/

KDE/Qt (Qt4), Gnome/GTK+ (Cairo) all move in this direction.

Regards. Valeriy

++
Perhaps, me just re-inventing the wheel

[quote=“Valeriy Onuchin”]Hi Valeri Fine,
Perhaps, me just re-inventing the wheel[/quote]

Correct, I agree.

“Good programmers know what to write.
Great ones know what to rewrite (and reuse).”

“The Cathedral and the Bazaar”

Hi Valeri,
we submitted changes in TImage to CVS.
Could you check it? Any critics accepted.
We have a chance to correct it before release.

Thanks. Regards. Valeriy

[quote=“jwodin”]Is there an easy way to read in an image (JPEG, GIF, BMP, whatever…) and get the actual pixel information out in an array or histogram? For example, if I have a 400x300 grayscale BMP, can I read it in and output the pixel grayscale data into an array or TH2F (I’d like to do this so I can do some processing and fitting on the image data).

jesse wodin[/quote]

I have the same problem. And I have wasted almost a whole day :open_mouth: trying to convert a greyscale 8bit .bmp into a TH2D histogram. Please point me to the function layed out by Valeriy: TH2D GetHist(…)
As far as I understand this thread has not solved the initial problem adequately.
There must be a simple way to fill a histogram from an picture / image?

Cheers, Christian

I would suggest you look at $ROOTSYS/tutorials/image/

Yes, of course. I checked the “image” tutorials, but could not find any help.

I thought that GetArgb() would do the job ?