/// <summary> /// Creates the final image after scaling from /// the range (Min, Max) to [0,255] /// </summary> /// <param name="colour">Colour to be applied</param> void CreateFinalImage(AlgorithmParameter colour) { int height = CurrentHeight; int width = CurrentWidth; int i, j, w1, w2; double diff = dMax - dMin; if (diff < 1) // What if diff is equal to zero? { diff = 1.0; } double factor = 255.0 / diff; double dVal, dVal1; byte bVal; for (j = 0; j < height; ++j) { w2 = j * width; for (i = 0; i < width; ++i) { w1 = w2 + i; dVal1 = pixDouble[w1]; dVal = (dVal1 - dMin) * factor; bVal = Convert.ToByte(dVal); SetBackgroundColour(colour, w1, bVal); } } }
/// <summary> /// Set the background colour /// </summary> /// <param name="colour"></param> /// <param name="i1"></param> /// <param name="value"></param> /// <param name="isSave"></param> public void SetBackgroundColour(AlgorithmParameter colour, int i1, byte value) { if (colour.Value == 1) // Red only { pixels8RedResult[i1] = value; pixels8GreenResult[i1] = 0; pixels8BlueResult[i1] = 0; } else if (colour.Value == 2) // Green only { pixels8RedResult[i1] = 0; pixels8GreenResult[i1] = value; pixels8BlueResult[i1] = 0; } else if (colour.Value == 3) // Blue only { pixels8RedResult[i1] = 0; pixels8GreenResult[i1] = 0; pixels8BlueResult[i1] = value; } else if (colour.Value == 4) // Green and Blue = Cyan { pixels8RedResult[i1] = 0; pixels8GreenResult[i1] = value; pixels8BlueResult[i1] = value; } else if (colour.Value == 5) // Red and Blue = Magenta { pixels8RedResult[i1] = value; pixels8GreenResult[i1] = 0; pixels8BlueResult[i1] = value; } else if (colour.Value == 6) // Red and Green = Yellow { pixels8RedResult[i1] = value; pixels8GreenResult[i1] = value; pixels8BlueResult[i1] = 0; } else { pixels8RedResult[i1] = value; pixels8GreenResult[i1] = value; pixels8BlueResult[i1] = value; } }
protected void SetBackgroundColour(AlgorithmParameter colour, int i1, byte value) { currentLoadedImage.SetBackgroundColour(colour, i1, value); }