Skip to content

JPEG QUALITY to Q=95 AND RES_CORRECTION#194

Open
titionex wants to merge 2 commits into
mahmoodlab:mainfrom
titionex:titionex-patch-1-converter
Open

JPEG QUALITY to Q=95 AND RES_CORRECTION#194
titionex wants to merge 2 commits into
mahmoodlab:mainfrom
titionex:titionex-patch-1-converter

Conversation

@titionex
Copy link
Copy Markdown

JPEG QUALITY to Q=95 AND RES_CORRECTION
This PR introduces two important fixes to the image conversion process in Converter.py:

JPEG Quality Enhancement: Forced JPEG compression quality to Q=95. The default behavior of 'tiffsave' uses Q=75, which can lead to excessive compression artifacts. Increasing this value ensures better image fidelity for large-scale processing.

Resolution Correction (MPP): Fixed a bug where the original MPP (Microns Per Pixel) was being incorrectly reduced by a factor of 10 (e.g., scaling
0.25
down to
0.025
). This fix ensures that the spatial metadata remains accurate and consistent with the original slide resolution.

JPEG QUALITY to Q=95 AND RES_CORRECTION
Fix: move line to correct position
@guillaumejaume
Copy link
Copy Markdown
Contributor

Thanks for the PR.

On the MPP point, the current implementation is correct when mpp is in microns per pixel and TIFF resolution is stored with resunit=CM.

xres = 1.0 / (mpp * 1e-4)
yres = 1.0 / (mpp * 1e-4)

Why:

  • 1 µm = 1e-4 cm
  • mpp * 1e-4 gives cm/pixel
  • TIFF xres / yres expect pixels per cm

So the correct conversion is:

pixels/cm = 1 / (mpp * 1e-4)

For example, if mpp = 0.25, then xres = 40000, which is correct.

Using 1e-3 would convert to mm, not cm, so that would be wrong with resunit=CM.

The JPEG quality change is a separate discussion, but the proposed MPP “fix” is not correct as written.

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