enc_dot_dictionary.cc (2439B)
1 // Copyright (c) the JPEG XL Project Authors. All rights reserved. 2 // 3 // Use of this source code is governed by a BSD-style 4 // license that can be found in the LICENSE file. 5 6 #include "lib/jxl/enc_dot_dictionary.h" 7 8 #include <stddef.h> 9 #include <string.h> 10 11 #include <array> 12 13 #include "lib/jxl/base/override.h" 14 #include "lib/jxl/base/status.h" 15 #include "lib/jxl/chroma_from_luma.h" 16 #include "lib/jxl/enc_detect_dots.h" 17 #include "lib/jxl/enc_params.h" 18 #include "lib/jxl/image.h" 19 20 namespace jxl { 21 22 // Private implementation of Dictionary Encode/Decode 23 namespace { 24 25 /* Quantization constants for Ellipse dots */ 26 const size_t kEllipsePosQ = 2; // Quantization level for the position 27 const double kEllipseMinSigma = 0.1; // Minimum sigma value 28 const double kEllipseMaxSigma = 3.1; // Maximum Sigma value 29 const size_t kEllipseSigmaQ = 16; // Number of quantization levels for sigma 30 const size_t kEllipseAngleQ = 8; // Quantization level for the angle 31 // TODO(user): fix these values. 32 const std::array<double, 3> kEllipseMinIntensity{{-0.05, 0.0, -0.5}}; 33 const std::array<double, 3> kEllipseMaxIntensity{{0.05, 1.0, 0.4}}; 34 const std::array<size_t, 3> kEllipseIntensityQ{{10, 36, 10}}; 35 } // namespace 36 37 StatusOr<std::vector<PatchInfo>> FindDotDictionary( 38 const CompressParams& cparams, const Image3F& opsin, const Rect& rect, 39 const ColorCorrelationMap& cmap, ThreadPool* pool) { 40 if (ApplyOverride(cparams.dots, 41 cparams.butteraugli_distance >= kMinButteraugliForDots)) { 42 GaussianDetectParams ellipse_params; 43 ellipse_params.t_high = 0.04; 44 ellipse_params.t_low = 0.02; 45 ellipse_params.maxWinSize = 5; 46 ellipse_params.maxL2Loss = 0.005; 47 ellipse_params.maxCustomLoss = 300; 48 ellipse_params.minIntensity = 0.12; 49 ellipse_params.maxDistMeanMode = 1.0; 50 ellipse_params.maxNegPixels = 0; 51 ellipse_params.minScore = 12.0; 52 ellipse_params.maxCC = 100; 53 ellipse_params.percCC = 100; 54 EllipseQuantParams qParams{ 55 rect.xsize(), rect.ysize(), kEllipsePosQ, 56 kEllipseMinSigma, kEllipseMaxSigma, kEllipseSigmaQ, 57 kEllipseAngleQ, kEllipseMinIntensity, kEllipseMaxIntensity, 58 kEllipseIntensityQ, kEllipsePosQ <= 5, cmap.YtoXRatio(0), 59 cmap.YtoBRatio(0)}; 60 61 return DetectGaussianEllipses(opsin, rect, ellipse_params, qParams, pool); 62 } 63 std::vector<PatchInfo> nothing; 64 return nothing; 65 } 66 } // namespace jxl