-1

I am trying to use this example (see first answer): C# convert a 2D double array to and greyscale image I am getting this error: https://i.imgsafe.org/2226c81bdc.png

I am using:

using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
Community
  • 1
  • 1
Lion
  • 11
  • 1
    Without seeing your code how can we help you? Please show code in your question, screenshots of code are not helpful. – maccettura Feb 13 '17 at 21:22
  • 1
    See http://stackoverflow.com/questions/3049240/obtaining-the-min-and-max-of-a-two-dimensional-array-using-linq – dimpho Feb 13 '17 at 21:23
  • Also see this [answer](http://stackoverflow.com/a/15395139/5095502). The example you are using is incomplete, that person must be using an extension method such as the one I just linked, or they typed the code without actually testing it. – Quantic Feb 13 '17 at 21:24
  • try this.. double min = data.Cast().Min(); – GorvGoyl Feb 13 '17 at 21:26
  • Thank you, double min = data.Cast().Min(); worked! – Lion Feb 14 '17 at 14:58

1 Answers1

-1

My guess would be that the user who answered the question created an extension method similar to this:

public static double Min(this double[,] values)
{
    double min = double.MaxValue;

    foreach (var value in values)
    {
        if (value < min)
        {
            min = value;
        }
    }

    return min;
}

Plus a similar method for Max()

EDIT: The foreach loop could also be replaced with the data.Cast().Min() call as suggested by @JerryGoyal

Dmihawk
  • 534
  • 5
  • 12