I am going for one function that will classify an image as:

{G, GA, GZ, GAZ, RGB, RGBA, RGBZ, RGBAZ, INVALID}

where G stands for grayscale. This is work in progress, I am just
brainstorming. But let me convince you right away of one big positive
thing. We can have more such input validation and image classification
schemes. For example one for the command line user and one for the API
user. We can have more or less strict schemes. Imagine if we don't do this
and after a year we change our mind about what is an RGBA image, you would
have to change all the code in all the algorithms I will do. But if we do
this, you would just change the "scheme" I talk about. You feel like the
current rules are too strict? Fine, just change the scheme, don't change
the code all over the place.

Larry told me to ignore "channelnames", so for this classification I am
taking
into consideration only nchannels, alpha_channel and z_channel.

I provide definitions plus questions for each to provoke ideas.

1. G: (nchannels == 1 && alpha_channel == -1 && z_channel == -1).

Is an image with 1 channel and that specified as alpha channel, a grayscale
image?

2. GA: (nchannels == 2 && alpha_channel >= 0 && z_channel == -1).

What if the alpha channel is the first one, AG instead of GA? Is AG invalid?

3. GZ: similar reasoning as for GA.

4. GAZ: (nchannels == 3 && alpha_channel >= 0 && z_channel >= 0 &&
alpha_channel != z_channel).

What about GZA or AGZ, does order matter?

5. RGB: (nchannels == 3 && alpha_channel < 0 && z_channel < 0).

This is where having more schemes is good. You could have a not so strict
scheme and say RGB for an image with 3 channels no matter if alpha or z
channels
are specified. Or you could have a stricter scheme and say an RGB image has
3
channels and alpha and z channels are not specified.

6,7,8. Similar ideas.

9. INVALID: everything else.

Let me know what you think and let me emphasize again, I think this is very
important to solve now.
It will apply later for all the algorithms I will work on.
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to