Can you first tell us what the "contrast" operation does?

On Jun 22, 2012, at 12:28 PM, Stefan Stavrev wrote:

> I begin to work on the next operation ImageBufAlgo::contrast.
> It is dead simple and yet brings different things than "over".
> It has one input image, one float parameter, does not
> care about alpha channels, works with both grayscale
> and color images, etc.
> 
> I am working on input validation and I need your feedback on
> what is a grayscale image and what is a color image. I use 
> the variables nchannels, alpha_channel and z_channel from
> the spec to decide.
> 
> 1. What is a grayscale image?
> 
> These are the possible cases: {G, GA, GZ, GAZ}, depending
> on alpha and z channel being specified. G stands for grayscale.
> 
> I suggest we handle them all, we only care that there is one channel
> that is non-alpha and non-z, we treat it as grayscale and we assume
> it is the first channel.
> 
> 2. What is a color image?
> 
> I think a color image has exactly 3 non-alpha and non-z
> channels. I think we should not care if alpha or z channel
> are specified, and we should assume RGB channels hold
> the first three positions, 0, 1 and 2.
> 
> Summary: I propose this check in ImageBufAlgo::contrast
> to remove the bad cases. A is the one input image.
> 
> int has_alpha_A = (specA.alpha_channel >= 0);
> int has_z_A = (specA.z_channel >= 0);
> int non_alpha_z_channels_A = specA.nchannels - has_alpha_A - has_z_A;
> 
> if (non_alpha_z_channels_A != 1
>     || non_alpha_z_channels_A != 3) {
>     return false;
> }
> 
> Then in the function where the algorithm is, and all types are 
> specialized, contrast_RA, I can have this:
> 
> if (non_alpha_z_channels_A == 1){
>     // algorithm for grayscale image
> } else if (non_alpha_z_channels_A == 3) {
>     // algorithm for color image
> }
> 
> Stefan
> _______________________________________________
> Oiio-dev mailing list
> [email protected]
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

--
Larry Gritz
[email protected]


_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to