我有一张图片。该图像由numpy.array类型表示。
int sum = 0;
for (int i = 0; i < rows; i++)
{
int[] numbers = Console.ReadLine()
.Split(", ", StringSplitOptions.RemoveEmptyEntries)
.Select(int.Parse)
.ToArray();
sum += numbers.Sum(); //Calculate sum of all numbers in a row and add it to existing sum variable.
//I do not know how to add the elements here
}
Console.WriteLine("Sum of all numbers" + sum); //print sum of all numbers i.e. 76
如何将数组表示的图像转换为如下所示的灰度。
array([[[165, 173, 184],
[170, 178, 189],
[171, 179, 190],
...,
[[ 4, 12, 1],
[ 3, 11, 0],
[ 6, 14, 1],
...,
[ 36, 32, 21],
[ 27, 23, 12],
[ 22, 18, 7]]], dtype=uint8)