Skip to content

Improving visual weighting code and implementation.#311

Open
aous72 wants to merge 9 commits into
masterfrom
improve_vw
Open

Improving visual weighting code and implementation.#311
aous72 wants to merge 9 commits into
masterfrom
improve_vw

Conversation

@aous72

@aous72 aous72 commented Jul 1, 2026

Copy link
Copy Markdown
Owner

This changes visual weighting in a few ways:

  • Replaced std::vector with open_htj2k::visual_weights, which uses std::array<T, 96>; we did this because std::vector needs new/delete, which is unnecessary.
  • Replaced double with float because these weights are inaccurate and therefore the precision of double is not needed.
  • Historically, when the end user does not specify a quantization step size for irreversible wavelet transform, we set the step size to 2^-bit_depth. In this commit, in lines 1324-1325, we set the quantization step size to 2^-min(16, bit_depth), thus preventing a quantization step size smaller than 2^-bit_depth when the end user does not specify it.

@palemieux Please have a look and let me know if you have any concerns.

aous72 added 2 commits July 1, 2026 20:05
… the new/delete. A small change for bit-depth-based quantization; now it is limited to 2^-16, if not explicitly chosen.
// visual array type
using visual_weighting_array = std::array<float, max_weight_size>;
// structure for our visual weights
class visual_weights {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I am not a big fan of this kind of shim that is used only for initialization purposes. I would instead use std::array[] directly.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your comment.
You need to to keep a count of how many entries were used; if not they you rely on the producer and consumer using the same number of entries -- that is the only reason.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Since it is not a generic array, I would

  • use more semantically accurate terms, e.g., count instead of size
  • remove clear() since it is never used and I cannot imagine a situation where you would want to c;lear visual weights.
  • replace set_weights() with a constructor
  • remove push_back()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... actually, why not make the visual weight generation function static members of the visual_weights class so that we do not need to expose any accessor methods.

@aous72

aous72 commented Jul 3, 2026

Copy link
Copy Markdown
Owner Author

@palemieux I followed you suggestion. Have a look and let me know if you have any concerns, improvements. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants