Beispiel #1
0
        private IEnumerable <TPixelComponent> InvertRowComponent <TPixelComponent>(IEnumerable <TPixelComponent> row,
                                                                                   NetpbmImage <TPixelComponent> image, HashSet <int> componentIndices, Component from, Component to)
        {
            var componentCount = image.Header.Components.Count;
            var oldRowPixels   = row.Batch(componentCount);

            foreach (var oldPixel in oldRowPixels)
            {
                var oldPixelArray = oldPixel.ToArray();
                for (int c = 0; c < componentCount; ++c)
                {
                    if (componentIndices.Contains(c))
                    {
                        yield return(image.InvertPixelValue(oldPixelArray[c]));
                    }
                    else
                    {
                        yield return(oldPixelArray[c]);
                    }
                }
            }
        }