/// <summary> /// Returns a bitmap with a gradient colored DistributionArray with the given size. /// </summary> /// <param name="heatMapBmp">Bitmap to save the heatmap to.</param> /// <param name="gradientBmp">Bitmap with gradient colors</param> /// <param name="size">new bitmap size</param> /// <param name="distributionArray">fixation distributions array</param> /// <returns>heat map bitmap</returns> internal static Bitmap CreateHeatMap( PaletteBitmap heatMapBmp, PaletteBitmap gradientBmp, Size size, float[,] distributionArray) { // get image size int width = size.Width; int height = size.Height; // for each line for (int y = 0; y < height; y++) { // for each pixel for (int x = 0; x < width; x++) { heatMapBmp.SetPixel(x, y, gradientBmp.GetPixel((int)distributionArray[x, y], 0)); } } return((Bitmap)heatMapBmp.Image.Clone()); }
/// <summary> /// This static method creates a heatmap /// from the brightness of the given b/w image where the colors are /// set using the given gradient colored bitmap. /// </summary> /// <param name="heatMapBmp">A <see cref="PaletteBitmap"/> thats /// contents should be overwritten with new heatmap</param> /// <param name="gradientBmp">A <see cref="PaletteBitmap"/> which is gradient /// colored.</param> /// <param name="size">The <see cref="Size"/> of the heatmap.</param> /// <param name="channelFilename">The filename with the b/w image.</param> /// <returns>A <see cref="Bitmap"/> with the new heat map</returns> internal static Bitmap CreateHeatMapFromBWImage( PaletteBitmap heatMapBmp, PaletteBitmap gradientBmp, Size size, string channelFilename) { // get heat map size int newWidth = size.Width; int newHeight = size.Height; if (!System.IO.File.Exists(channelFilename)) { throw new System.IO.FileNotFoundException(); } // Rescale source image to heat map size. Bitmap srcImage = (Bitmap)Images.GetImageOfFile(channelFilename); Bitmap rescaledSrcImage = Images.RescaleImage(new Size(newWidth, newHeight), srcImage, true); PaletteBitmap output = new PaletteBitmap(rescaledSrcImage); // for each line for (int y = 0; y < newHeight; y++) { // for each pixel for (int x = 0; x < newWidth; x++) { heatMapBmp.SetPixel( x, y, gradientBmp.GetPixel((int)(output.GetPixel(x, y).GetBrightness() * (NUMCOLORS - 1)), 0)); } } return(heatMapBmp.Image); }
/// <summary> /// Returns a bitmap with a gradient colored DistributionArray with the given size. /// </summary> /// <param name="heatMapBmp">Bitmap to save the heatmap to.</param> /// <param name="gradientBmp">Bitmap with gradient colors</param> /// <param name="size">new bitmap size</param> /// <param name="distributionArray">fixation distributions array</param> /// <returns>heat map bitmap</returns> internal static Bitmap CreateHeatMap( PaletteBitmap heatMapBmp, PaletteBitmap gradientBmp, Size size, float[,] distributionArray) { // get image size int width = size.Width; int height = size.Height; // for each line for (int y = 0; y < height; y++) { // for each pixel for (int x = 0; x < width; x++) { heatMapBmp.SetPixel(x, y, gradientBmp.GetPixel((int)distributionArray[x, y], 0)); } } return (Bitmap)heatMapBmp.Image.Clone(); }
/// <summary> /// This static method creates a heatmap /// from the brightness of the given b/w image where the colors are /// set using the given gradient colored bitmap. /// </summary> /// <param name="heatMapBmp">A <see cref="PaletteBitmap"/> thats /// contents should be overwritten with new heatmap</param> /// <param name="gradientBmp">A <see cref="PaletteBitmap"/> which is gradient /// colored.</param> /// <param name="size">The <see cref="Size"/> of the heatmap.</param> /// <param name="channelFilename">The filename with the b/w image.</param> /// <returns>A <see cref="Bitmap"/> with the new heat map</returns> internal static Bitmap CreateHeatMapFromBWImage( PaletteBitmap heatMapBmp, PaletteBitmap gradientBmp, Size size, string channelFilename) { // get heat map size int newWidth = size.Width; int newHeight = size.Height; if (!System.IO.File.Exists(channelFilename)) { throw new System.IO.FileNotFoundException(); } // Rescale source image to heat map size. Bitmap srcImage = (Bitmap)Images.GetImageOfFile(channelFilename); Bitmap rescaledSrcImage = Images.RescaleImage(new Size(newWidth, newHeight), srcImage, true); PaletteBitmap output = new PaletteBitmap(rescaledSrcImage); // for each line for (int y = 0; y < newHeight; y++) { // for each pixel for (int x = 0; x < newWidth; x++) { heatMapBmp.SetPixel( x, y, gradientBmp.GetPixel((int)(output.GetPixel(x, y).GetBrightness() * (NUMCOLORS - 1)), 0)); } } return heatMapBmp.Image; }