I have a sequence of elements [(12, 34); (56, 78); ...]
and I want to turn it into [(XXX, XXX, XXX); (XXX, XXX, XXX); ...]
where (XXX, XXX, XXX)
is the (R, G, B) of the given tuple/coordinates, e.g., (12, 34)
. According to .NET documentation, System.Drawing.Bitmap.GetPixel
returns System.Drawing.Color
and you can just call Color.R
, Color.B
and Color.G
to get the colour value as a byte
.
This is what I've got so far:
let neighbourColor (img : System.Drawing.Bitmap) (s : seq<int * int>) =
s |> Seq.collect(fun e -> s |> img.GetPixel(fst(e), snd(e)) |> Seq.map(fun c -> (c.R, c.G, c.B)))
For every element e
in sequence s
, get the color of e which is a tuple of coordinates on image img
, then pass it to Seq.map
to transform it into (Red, Green, Blue) and collect it as a new sequence neighbourColor
.
Basically I want to turn seq<int*int>
into seq<byte*byte*byte>
.