protected override void DoCompareFrames(FrameTransition transition) { RGBData frame1 = transition.Frame1; RGBData frame2 = transition.Frame2; int index = transition.Index; if (outputImageData == null) { outputImageData = new ImageData(new Bitmap(frames, frame1.Rows * 3)); outputImageData.Lock(); } for (int i = 0; i < frame1.Rows; i++) { outputImageData.Data.SetR(counter, i, frame1.GetR(frame1.Columns / 4, i)); outputImageData.Data.SetG(counter, i, frame1.GetG(frame1.Columns / 4, i)); outputImageData.Data.SetB(counter, i, frame1.GetB(frame1.Columns / 4, i)); outputImageData.Data.SetR(counter, i + frame1.Rows, frame1.GetR(frame1.Columns / 2, i)); outputImageData.Data.SetG(counter, i + frame1.Rows, frame1.GetG(frame1.Columns / 2, i)); outputImageData.Data.SetB(counter, i + frame1.Rows, frame1.GetB(frame1.Columns / 2, i)); outputImageData.Data.SetR(counter, i + frame1.Rows * 2, frame1.GetR(frame1.Columns * 3 / 4, i)); outputImageData.Data.SetG(counter, i + frame1.Rows * 2, frame1.GetG(frame1.Columns * 3 / 4, i)); outputImageData.Data.SetB(counter, i + frame1.Rows * 2, frame1.GetB(frame1.Columns * 3 / 4, i)); } }
/// <summary> /// Draw the given image on this image. /// </summary> /// <param name="srcData">The image to draw</param> /// <param name="destX">The X position on this image.</param> /// <param name="destY">The Y position on this image.</param> /// <param name="srcX">The X position on the source image.</param> /// <param name="srcY">The Y position on the source image.</param> /// <param name="srcWidth">The width of the source image to draw.</param> /// <param name="srcHeight">The height of the source image to draw.</param> public void Draw(RGBData srcData, int destX, int destY, int srcX, int srcY, int srcWidth, int srcHeight) { for (int j = 0; j < srcHeight - srcY; j++) { for (int i = 0; i < srcWidth - srcX; i++) { Data.SetR(destX + i, destY + j, srcData.GetR(i + srcX, j + srcY)); Data.SetG(destX + i, destY + j, srcData.GetG(i + srcX, j + srcY)); Data.SetB(destX + i, destY + j, srcData.GetB(i + srcX, j + srcY)); } } }
protected override void DoCompareFrames(FrameTransition frameTransition) { RGBData frame1 = frameTransition.Frame1; RGBData frame2 = frameTransition.Frame2; int index = frameTransition.Index; double sum = 0; for (int row = 0; row < frame1.Rows; row++) { for (int col = 0; col < frame1.Columns; col++) { double i1 = rFactor * frame1.GetR(col, row) + gFactor * frame1.GetG(col, row) + bFactor * frame1.GetB(col, row); sum += i1; } } result[index] = sum / (frame1.Columns * frame1.Rows); }
protected override void DoCompareFrames(FrameTransition transition) { RGBData frame1 = transition.Frame1; RGBData frame2 = transition.Frame2; int index = transition.Index; int[,,,,] histogram1 = new int[areas, areas, buckets, buckets, buckets]; int[,,,,] histogram2 = new int[areas, areas, buckets, buckets, buckets]; int factor = 256 / buckets; double colSize = frame1.Columns / (double)areas; double rowSize = frame2.Rows / (double)areas; for (int row = 0; row < frame1.Rows; row++) { for (int col = 0; col < frame1.Columns; col++) { int r1 = frame1.GetR(col, row); int g1 = frame1.GetG(col, row); int b1 = frame1.GetB(col, row); histogram1[(int)(col / colSize), (int)(row / rowSize), r1 / factor, g1 / factor, b1 / factor]++; int r2 = frame2.GetR(col, row); int g2 = frame2.GetG(col, row); int b2 = frame2.GetB(col, row); histogram2[(int)(col / colSize), (int)(row / rowSize), r2 / factor, g2 / factor, b2 / factor]++; } } List <int> sums = new List <int>(); for (int row = 0; row < areas; row++) { for (int col = 0; col < areas; col++) { int sum = 0; for (int k = 0; k < buckets; k++) { for (int j = 0; j < buckets; j++) { for (int i = 0; i < buckets; i++) { sum += Math.Abs(histogram1[col, row, i, j, k] - histogram2[col, row, i, j, k]); } } } sums.Add(sum); } } int removeCount = (int)(sums.Count * percentRemove); if (removeCount > 0) { sums = sums.OrderBy(s => s).ToList(); for (int i = 0; i < removeCount; i++) { sums.RemoveAt(sums.Count - 1); } } double max = frame1.Columns * frame1.Rows * 2 - (colSize * rowSize * removeCount); result[index] = sums.Sum() / max; }