@@ -72,6 +72,29 @@ Array bulkify(const Array &z,
7272 glm::vec2 center = {0 .5f , 0 .5f },
7373 glm::vec4 bbox = {0 .f , 1 .f , 0 .f , 1 .f });
7474
75+ /* *
76+ * @brief Reduce quantization artifacts using dithering and smoothing.
77+ *
78+ * Adds white noise dithering to the input array and applies iterative Laplacian
79+ * filtering to smooth quantization steps.
80+ *
81+ * @param array Input quantized array.
82+ * @param seed Random seed used for dithering noise generation.
83+ * @param dither_amplitude Amplitude of the added white noise.
84+ * @param filtering_iterations Number of Laplacian smoothing iterations.
85+ * @return Dequantized and smoothed array.
86+ *
87+ * **Example**
88+ * @include ex_dequantize.cpp
89+ *
90+ * **Result**
91+ * @image html ex_dequantize.png
92+ */
93+ Array dequantize (const Array &array,
94+ std::uint32_t seed,
95+ float dither_amplitude = 0 .01f ,
96+ int filtering_iterations = 1 );
97+
7598/* *
7699 * @brief Apply histogram equalization to the array values.
77100 *
@@ -889,6 +912,42 @@ void normal_displacement(Array &array,
889912void plateau (Array &array, const Array *p_mask, int ir, float factor);
890913
891914void plateau (Array &array, int ir, float factor); // /< @overload
915+
916+ /* *
917+ * @brief Quantize array values into discrete levels.
918+ *
919+ * Values are clamped to the range [vmin, vmax] and remapped to `nlevels`
920+ * uniformly distributed discrete values.
921+ *
922+ * @param array Input array.
923+ * @param nlevels Number of quantization levels.
924+ * @param vmin Minimum clamp value.
925+ * @param vmax Maximum clamp value.
926+ * @return Quantized array.
927+ *
928+ * **Example**
929+ * @include ex_dequantize.cpp
930+ *
931+ * **Result**
932+ * @image html ex_dequantize.png
933+ */
934+ Array quantize (const Array &array, int nlevels, float vmin, float vmax);
935+
936+ /* *
937+ * @brief Quantize array values using the array min/max range.
938+ *
939+ * @param array Input array.
940+ * @param nlevels Number of quantization levels.
941+ * @return Quantized array.
942+ *
943+ * **Example**
944+ * @include ex_dequantize.cpp
945+ *
946+ * **Result**
947+ * @image html ex_dequantize.png
948+ */
949+ Array quantize (const Array &array, int nlevels);
950+
892951/* *
893952 * @brief Transform heightmap to give a "billow" like appearance.
894953 *
0 commit comments