protected void Exposure(string param) { if (inputImage == null) { return; } Dictionary <string, string> p = Util.ParseKeyValueList(param); double gamma = 0.0; if (p.Count > 0) { // gamma=<float-number> Util.TryParse(p, "gamma", ref gamma); // exp=<float-number> // must not change the value if the 'exp' key is not present Util.TryParse(p, "exp", ref exposure); // sub=<sub-factor> if (Util.TryParse(p, "sub", ref subFactor)) { if (subFactor < 1) { subFactor = 1; } if (subFactor == 1) { if (inputImage != origInputImage) { inputImage = origInputImage; } } else if (inputImage.Width * subFactor != origInputImage.Width) { inputImage = new FloatImage(origInputImage); inputImage.Resize(subFactor); } } } sw.Restart(); outputImage = inputImage.Exposure(outputImage, exposure, gamma); sw.Stop(); labelStatus.Text = string.Format(CultureInfo.InvariantCulture, "{0:f1} EV, exp: {1} ms", contrast, sw.ElapsedMilliseconds); setImage(ref outputImage, outputImage); }
/// <summary> /// compute dct robust image hash /// </summary> /// <param name="image">An image to compute DCT hash.</param> /// <returns>hash of type ulong</returns> public static ulong ComputeDctHash(IByteImage image) { FloatImage img = image.Convolve(new FloatImage(7, 7, 1)); FloatImage resized = img.Resize(32, 32); FloatImage coeff = _DctMatrix ?? (_DctMatrix = CreateDctMatrix(32)); FloatImage dctImage = coeff.MatrixMultiply(resized).MatrixMultiply(coeff, isTransposed: true); float median = GetMedianOf64(dctImage); ulong r = 0ul; for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { r |= dctImage[x + 1, y + 1] > median ? (1ul << (x + 8 * y)) : 0; } } return(r); }