Log in

View Full Version : ImageReader/Writer and 8-bit grayscale


weaker
25th March 2008, 12:09
Hi all,

I'm a newly registered user but I am reading the Doom9-forums for quite some years already. This time the forum search function didn't get me the info I need and I need to start a thread.

I want to work with 8-bit grayscale BMP files in AviSynth and these are the problems I encountered:

In the AviSynth wiki http://avisynth.org/mediawiki/ImageSource I read things I find somehow confusing:

At the very bottom I read
v2.60 Opening grayscale images (as Y8) added; EBMP supports all color formats.

As I'm informed, 2.57 is the stable version and 2.58 is in alpha stage. So is this just planned for 2.60 or what does that mean? Of course I tried pixel_type = Y8 but 2.57 doesn't accept it and throws an error.
If this is a hint to a nonexistant future version that's fine but not marked as such. I find it confusing to find things in a wiki that don't work or are intended for the future.

The next confusion arises here
Grayscale BMPs are not read and written correctly by DevIL. They should be opened using DevIL=false.
Neither DevIL=true nor DevIL=false succeed in opening the images. :-(

So I sought after updating the DevIL lib and after googling around I found that the DevIL lib is available in a newer version but it looks like AviSynth doesn't use the DLL but links statically to it. That'd require me to recompile AviSynth with the new DevIL lib which surely will introduce other dependencies and I really don't want to mess around with compiling AviSynth on my own.


After long search I found the CoronaSource/ImageSequence-Plugin from WarpEnterprises that does the trick.
Is there a reason that it is not included in the default AviSynth-distribution as the default way to open 8-bit greyscale images?

And last but not least: Does a plugin exist that is able to write 8-bit greyscale images?
I really like AviSynth but with 8-bit greyscale images I seem to have hit a weak spot.

Best regards,
weaker

Wilbert
25th March 2008, 19:19
As I'm informed, 2.57 is the stable version and 2.58 is in alpha stage. So is this just planned for 2.60 or what does that mean? Of course I tried pixel_type = Y8 but 2.57 doesn't accept it and throws an error.
It means what it says. It will available when v2.60 is released (it's not planned, because the code is already there, but there is no official version of 2.60 out yet).

The next confusion arises here

Grayscale BMPs are not read and written correctly by DevIL. They should be opened using DevIL=false.
Neither DevIL=true nor DevIL=false succeed in opening the images. :-(

If you look at the changelog you will see that grayscale images will be supported in v2.60. So that comment applies when you use the unofficial version of v2.60.

As a side note:
So I sought after updating the DevIL lib and after googling around I found that the DevIL lib is available in a newer version but it looks like AviSynth doesn't use the DLL but links statically to it. That'd require me to recompile AviSynth with the new DevIL lib which surely will introduce other dependencies and I really don't want to mess around with compiling AviSynth on my own.
All you need is devil.lib and il.h (no other dependencies are involved). If you want to experiment with it and correct stuff (like read/write support of Greyscale BMP with DevIL or write support in AviSynth itself), you need to compile v2.60 on your own.

After long search I found the CoronaSource/ImageSequence-Plugin from WarpEnterprises that does the trick.
Is there a reason that it is not included in the default AviSynth-distribution as the default way to open 8-bit greyscale images?
You should be able to open those as RGB (with ImageSource). Doesn't that work?

weaker
25th March 2008, 22:35
Thank you for your reply.
when you use the unofficial version of v2.60
I was only able to find a very old (and therefore very early) pre-alpha version of 2.60. I haven't tested it yet but I presume that it might not be very stable and/or compatible with existing "third party" plugins.

I found that comment in the wiki confusing because it took me a while to find that there was indeed a 2.60 version in the making. (I don't know too much about AviSynth development but does that mean that 2.58 and 2.60 are different development branches which are developed concurrently?)
You should be able to open those as RGB (with ImageSource)
I will try that (again). I don't remember exactly but I think I tried that too. CoronaSequence works (I'm using it atm).

And have you perhaps heard of an 8-bit greyscale capable writing plugin?

Best regards,
weaker

Wilbert
25th March 2008, 23:09
I was only able to find a very old (and therefore very early) pre-alpha version of 2.60. I haven't tested it yet but I presume that it might not be very stable and/or compatible with existing "third party" plugins.
Yes, it's not very stable, but it won't crash your pc :) Third party plugins might work with it.

I found that comment in the wiki confusing because it took me a while to find that there was indeed a 2.60 version in the making.
Ok, i should clarify that. Thanks!

I don't know too much about AviSynth development but does that mean that 2.58 and 2.60 are different development branches which are developed concurrently?
Yes (but all 2.58 fixes are ported to 2.60).

And have you perhaps heard of an 8-bit greyscale capable writing plugin?
No, sorry. Perhaps the easiest approach would be to modify v2.58 to include support for it. It has been a while when i looked at it. But you need to use format=IL_LUMINANCE and copy the luma with ilSetPixels: http://openil.sourceforge.net/docs/index.php. Sorry, i don't have time to look at it at the moment.

bill_baroud
26th March 2008, 10:34
Why do you need to _write_ 8 bits bitmap ? AFAIK, avisynth do not support this colorspace, so (almost) no filter can be used on that kind of material, and is supposed to _frameserve_ bitmap, so it's sound pretty useless.

Could you describe what you intend to do ? How do you import your 8 bits material btw ? I used rawsource and used only the Y plane in YV12 for my debayer plugin but i don't know if that applies to your case.

Wilbert
26th March 2008, 18:22
Why do you need to _write_ 8 bits bitmap ? AFAIK, avisynth do not support this colorspace, so (almost) no filter can be used on that kind of material, and is supposed to _frameserve_ bitmap, so it's sound pretty useless.
I think it would be great if you can open this as YCbCr, process the luma, and save back as greyscale bitmap again.

Could you describe what you intend to do ? How do you import your 8 bits material btw ? I used rawsource and used only the Y plane in YV12 for my debayer plugin but i don't know if that applies to your case.
RawSource can't open BMP.

weaker
30th March 2008, 13:27
Thanks for all your answers!

@bill_baroud:
I'm not using AviSynth as a frameserver but rather as a nice scriptable environment to do some basic video processing before the video is handed to another program (completely independent of AviSynth).

I know that creating intermediate files somehow defeats the purpose of AviSynth but it does what I want in a very comfortable way. If those intermediate files were 8-bit they had only a third of the size (which starts to matter if you have one or three terabytes). I try to avoid another conversion from 24-bit to 8-bit. Temporarily I'd need four times the space of the input data. It doesn't matter to me that AviSynth works with 24-bits (or 32-bit ?) internally. I just want small 8-bit output files.

The video is available as an image sequence for other reasons (that program that follows after AviSynth processing.)

weaker
3rd April 2008, 09:39
Short update: 2.60 alpha does what I want (at least with PNG, not with bmp) :thanks:
ImageWriter plugin however flips the image upside down which is easy to fix. It doesn't matter that this way the preview is wrong.