Link to home
Start Free TrialLog in
Avatar of websss
websssFlag for Kenya

asked on

convert from list to float[,] using linq

I need to convert a list to Float[,] array

I have the following classes and data

 public class ThermalData
    {
        public int X { get; set; } //image pixel position x (X-Coordinate)
        public int Y { get; set; } //image pixel position y (Y-Coordinate)
        public double T { get; set; }  //pixel data (Temperature reading)
}


public class FlirImage
{
  public int Width { get; set; }
  public int Height { get; set; }
  public IList<ThermalData> ThermalData{ get; set; }
}

Open in new window


I currently have a list of each pixel in a 320x240 image that contains an instance of TemperatureData class, which contains the x,y coordinates on image, and the pixels heat reading.

I now need to convert this data a float array without looping through each pixel, is there a very fast efficient linq way of doing this?

This is what i have
User generated image
And I need something like this
User generated image
based on the last image, it would be:

 [X-Coordinate, Y-Coordinate] | Temperature reading


Any ideas how i do this?
ASKER CERTIFIED SOLUTION
Avatar of louisfr
louisfr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you are concerned about loop speed, you can do a for loop instead of a foreach which is about 4-5 times cheaper.
Avatar of louisfr
louisfr

I only gain 20% on my tests, but if you're concerned about 4 milliseconds being too big, then, yes, use a for loop.