zhaojiahai / aforge

Automatically exported from code.google.com/p/aforge
Other
0 stars 0 forks source link

RGB Order is used differently in different places of source files.. #86

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I'm using AForge.NET framework version 1.7.0

Index of R, G, B components in your RGB class is defined as follows:
R = 2;
G = 1;
B = 0;

When i investigated different parts of the source codes of your library i 
found that ordering is different in some places.

For example:

1) In Pixellate Filter's source code, and in the other filters, the 
indexing is used as follows:

                        // for each pixel
                        for (x = 0; x < width; x++, src += 3)
                        {
                            k = (x / pixelWidth) * 3;
                            tmp[k] += src[RGB.R];
                            tmp[k + 1] += src[RGB.G];
                            tmp[k + 2] += src[RGB.B];
                        }

--------------------------------

2) In BlobCounterBase Filter's source code the indexing is used as follows:

                            if ( objectLabels[p] == label )
                            {
                                // copy pixel
                                *dst = *src;

                                if ( pixelSize > 1 )
                                {
                                    dst[1] = src[1];
                                    dst[2] = src[2];
                                }
                            }

--------------------------------

The indexing in the first example is RGB (2, 1, 0) but in the second 
example it is BGR (0, 1, 2). I think that in the first example the 
ordering should be BGR.
Is this different indexing of RGB normal in those examples?

Original issue reported on code.google.com by agentji...@gmail.com on 19 Jan 2009 at 5:52

GoogleCodeExporter commented 8 years ago
In both case there are no errors with the order:

1) In Pixellate filter the temporary array is used to accumulate some values. 
Then 
this array is processed according to the order, which was used to store values 
there.

2) The second sample is just copying of pixels. You may copy pixel values as 
you 
would like as long as dest.R = source.R, etc.

Note: questions are not issues. Questions should go to forum.

Original comment by andrew.k...@gmail.com on 19 Jan 2009 at 7:08