libjxl

FORK: libjxl patches used on blog
git clone https://git.neptards.moe/blog/libjxl.git
Log | Files | Refs | Submodules | README | LICENSE

enc_detect_dots.h (2281B)


      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 // We attempt to remove dots, or speckle from images using Gaussian blur.
      7 #ifndef LIB_JXL_ENC_DETECT_DOTS_H_
      8 #define LIB_JXL_ENC_DETECT_DOTS_H_
      9 
     10 #include <stddef.h>
     11 #include <stdint.h>
     12 
     13 #include <array>
     14 #include <vector>
     15 
     16 #include "lib/jxl/base/data_parallel.h"
     17 #include "lib/jxl/enc_patch_dictionary.h"
     18 #include "lib/jxl/image.h"
     19 
     20 namespace jxl {
     21 
     22 struct GaussianDetectParams {
     23   double t_high = 0;  // at least one pixel must have larger energy than t_high
     24   double t_low = 0;   // all pixels must have a larger energy than tLow
     25   uint32_t maxWinSize = 0;  // discard dots larger than this containing window
     26   double maxL2Loss = 0;
     27   double maxCustomLoss = 0;
     28   double minIntensity = 0;     // If the intensity is too low, discard it
     29   double maxDistMeanMode = 0;  // The mean and the mode must be close
     30   size_t maxNegPixels = 0;     // Maximum number of negative pixel
     31   size_t minScore = 0;
     32   size_t maxCC = 50;   // Maximum number of CC to keep
     33   size_t percCC = 15;  // Percentage in [0,100] of CC to keep
     34 };
     35 
     36 // Ellipse Quantization Params
     37 struct EllipseQuantParams {
     38   size_t xsize;      // Image size in x
     39   size_t ysize;      // Image size in y
     40   size_t qPosition;  // Position quantization delta
     41   // Quantization for the Gaussian sigma parameters
     42   double minSigma;
     43   double maxSigma;
     44   size_t qSigma;  // number of quantization levels
     45   // Quantization for the rotation angle (between -pi and pi)
     46   size_t qAngle;
     47   // Quantization for the intensity
     48   std::array<double, 3> minIntensity;
     49   std::array<double, 3> maxIntensity;
     50   std::array<size_t, 3> qIntensity;  // number of quantization levels
     51   // Extra parameters for the encoding
     52   bool subtractQuantized;  // Should we subtract quantized or detected dots?
     53   float ytox;
     54   float ytob;
     55 
     56   void QuantPositionSize(size_t* xsize, size_t* ysize) const;
     57 };
     58 
     59 // Detects dots in XYB image.
     60 StatusOr<std::vector<PatchInfo>> DetectGaussianEllipses(
     61     const Image3F& opsin, const Rect& rect, const GaussianDetectParams& params,
     62     const EllipseQuantParams& qParams, ThreadPool* pool);
     63 
     64 }  // namespace jxl
     65 
     66 #endif  // LIB_JXL_ENC_DETECT_DOTS_H_