Try:
Public Function CalculateMeanError(ByVal target As ImageBuffer, Optional ByVal parallelTaskCount As Int32 = 4) As Double
Guard.CheckNull(target, "target")
Dim totalError As Int64 = 0
Dim fn As Func(Of Pixel, Pixel, Boolean) = Function(sourcePixel As Pixel, targetPixel As Pixel)
Dim sourceColor As Color = GetColorFromPixel(sourcePixel)
Dim targetColor As Color = GetColorFromPixel(targetPixel)
totalError += ColorModelHelper.GetColorEuclideanDistance(ColorModel.RedGreenBlue, sourceColor, targetColor)
Return False
End Function
Dim standardPath As IList(Of Point) = New StandardPathProvider().GetPointPath(Width, Height)
TransformPerPixel(target, standardPath, fn, parallelTaskCount)
Return Math.Sqrt(totalError / (3.0 * Width * Height))
End Function
Lambda Expressions (Visual Basic) | Microsoft Docs[
^]