private TiffYCbCrConverter8(TiffRational[] luma, TiffRational[] referenceBlackWhite) { _expanderY = new CodingRangeExpander(referenceBlackWhite[0], referenceBlackWhite[1], 255); _expanderCb = new CodingRangeExpander(referenceBlackWhite[2], referenceBlackWhite[3], 127); _expanderCr = new CodingRangeExpander(referenceBlackWhite[4], referenceBlackWhite[5], 127); _converterFrom = new YCbCrToRgbConverter(luma[0], luma[1], luma[2]); _shrinkerY = new CodingRangeShrinker(referenceBlackWhite[0], referenceBlackWhite[1], 255); _shrinkerCb = new CodingRangeShrinker(referenceBlackWhite[2], referenceBlackWhite[3], 127); _shrinkerCr = new CodingRangeShrinker(referenceBlackWhite[4], referenceBlackWhite[5], 127); _converterTo = new RgbToYCbCrConverter(luma[0], luma[1], luma[2]); }
public static YCbCrPixel[,] Convert(RgbPixel[,] matrix) { var height = matrix.GetLength(0); var width = matrix.GetLength(1); var convertedMatrix = new YCbCrPixel[height, width]; for (var i = 0; i < height; i++) { for (var j = 0; j < width; j++) { convertedMatrix[i, j] = RgbToYCbCrConverter.Convert(matrix[i, j]); } } return(convertedMatrix); }
public void Rgb_ConvertToYCbCrAndBack_SameResult() { var rgb = new RgbPixel(50, 150, 255); var yCbCr = RgbToYCbCrConverter.Convert(rgb); var newRgb = YCbCrToRgbConverter.Convert(yCbCr); }