René's URL Explorer Experiment


Title: Contrast adjustment with 'eliminate outliers' failed for float images with high dynamic range · Issue #46 · PlotPyStack/PlotPy · GitHub

Open Graph Title: Contrast adjustment with 'eliminate outliers' failed for float images with high dynamic range · Issue #46 · PlotPyStack/PlotPy

X Title: Contrast adjustment with 'eliminate outliers' failed for float images with high dynamic range · Issue #46 · PlotPyStack/PlotPy

Description: 🐞 Problem Summary The hist_range_threshold function was designed to compute the value range covering a central percentage of the histogram mass (e.g. 98%), in order to eliminate symmetric outliers — similar to MATLAB’s Eliminate outliers...

Open Graph Description: 🐞 Problem Summary The hist_range_threshold function was designed to compute the value range covering a central percentage of the histogram mass (e.g. 98%), in order to eliminate symmetric outliers ...

X Description: 🐞 Problem Summary The hist_range_threshold function was designed to compute the value range covering a central percentage of the histogram mass (e.g. 98%), in order to eliminate symmetric outliers ...

Opengraph URL: https://github.com/PlotPyStack/PlotPy/issues/46

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Contrast adjustment with 'eliminate outliers' failed for float images with high dynamic range","articleBody":"## 🐞 Problem Summary\n\nThe `hist_range_threshold` function was designed to compute the value range covering a central percentage of the histogram mass (e.g. 98%), in order to eliminate symmetric outliers — similar to MATLAB’s *Eliminate outliers*.\n\nThis worked correctly for integer-valued images (e.g. 8-bit or 16-bit), where the first histogram bin typically corresponds to zero-valued pixels and can safely be ignored.\n\nHowever, when applied to **float-valued images**, the function produced incorrect results due to a mismatch between `hist` and `bin_edges`.\n\n## ⚠️ Observed Symptoms\n\n- The computed `(vmin, vmax)` bounds were sometimes shifted or too narrow/wide.\n- The assumption that the first bin should always be removed caused misalignment when `bin_edges` were non-integer floats (e.g. from `np.linspace`).\n- The end bin (`i_bin_max`) could point to the wrong edge when the alignment was lost.\n\n## ✅ Resolution\n\nWe reimplemented the function to:\n\n- **Remove the first bin only** if `bin_edges` are of integer type (typically meaning the histogram comes from an integer-valued image where zero has a special meaning).\n- Maintain the correct alignment between `hist[i]` and the interval `[bin_edges[i], bin_edges[i+1])`.\n- **Fix an off-by-one error** that previously caused inconsistencies, especially for edge cases like `percent = 0`.\n\n## 🎯 Additional Fix: Index Alignment\n\nAn important correction was made to the computation of the output range:\n\n- Previously, accessing `bin_edges[i_bin_max]` assumed that the end of the last bin was `bin_edges[-1]`, which was not guaranteed after trimming.\n- Now, we properly return `bin_edges[i_bin_min]` and `bin_edges[i_bin_max]`, based on explicitly corrected indices and consistent bin count logic.\n- As a result, setting `percent = 0` now returns a `(vmin, vmax)` that spans exactly one bin — meaning that **no contrast adjustment occurs** in this edge case.\n\n## 🧪 Final Function\n\n```python\nimport numpy as np\n\ndef hist_range_threshold(\n    hist: np.ndarray, bin_edges: np.ndarray, percent: float\n) -\u003e tuple[float, float]:\n    \"\"\"\n    Return the value range corresponding to the central `percent` of the histogram mass,\n    optionally excluding the first bin (assumed to represent zero-valued pixels in integer images).\n\n    Args:\n        hist: Histogram values (length N)\n        bin_edges: Bin edges (length N+1)\n        percent: Percent of the histogram mass to retain (between 0 and 100)\n\n    Returns:\n        (vmin, vmax): Value range corresponding to the central mass\n    \"\"\"\n    if not (0 \u003c= percent \u003c= 100):\n        raise ValueError(\"percent must be in [0, 100]\")\n\n    hist_len = len(hist)\n    i_offset = 0\n\n    # Remove first bin only for integer-based histograms (e.g. zero-valued pixels)\n    if np.issubdtype(bin_edges.dtype, np.integer):\n        hist = hist[1:]\n        i_offset = 1\n\n    threshold = 0.5 * percent / 100 * hist.sum()\n\n    i_bin_min = max(np.cumsum(hist).searchsorted(threshold) - i_offset, 0)\n    i_bin_max = hist_len - np.searchsorted(np.cumsum(np.flipud(hist)), threshold)\n\n    vmin, vmax = bin_edges[i_bin_min], bin_edges[i_bin_max]\n    return vmin, vmax\n","author":{"url":"https://github.com/PierreRaybaut","@type":"Person","name":"PierreRaybaut"},"datePublished":"2025-07-02T14:07:51.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/46/PlotPy/issues/46"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:a83f237d-3536-ef09-d89f-5a44e16dbd85
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB2DC:B4897:18FA30E:21B24C0:6972B4B2
html-safe-nonce19f03498107904fe087f3abe506f90e22c97852d53798321ab9a0328165e9330
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMkRDOkI0ODk3OjE4RkEzMEU6MjFCMjRDMDo2OTcyQjRCMiIsInZpc2l0b3JfaWQiOiIzMDAxMjkzNjYzMjYzNDM4MDAyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacae15df8014fe3b5c58b01ec5a7b37acd08084e6e146ebb9972efaa9c78819170
hovercard-subject-tagissue:3196054750
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PlotPyStack/PlotPy/46/issue_layout
twitter:imagehttps://opengraph.githubassets.com/0dc6029d3f872ee7f84f50930b07da5d5c939b3e4ccfc81e232e1a4f0d698584/PlotPyStack/PlotPy/issues/46
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/0dc6029d3f872ee7f84f50930b07da5d5c939b3e4ccfc81e232e1a4f0d698584/PlotPyStack/PlotPy/issues/46
og:image:alt🐞 Problem Summary The hist_range_threshold function was designed to compute the value range covering a central percentage of the histogram mass (e.g. 98%), in order to eliminate symmetric outliers ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamePierreRaybaut
hostnamegithub.com
expected-hostnamegithub.com
None51c0d0848f5569c6fa2198e9d69bd5f8f94a83c9fa3659e40728e7732afab130
turbo-cache-controlno-preview
go-importgithub.com/PlotPyStack/PlotPy git https://github.com/PlotPyStack/PlotPy.git
octolytics-dimension-user_id145201262
octolytics-dimension-user_loginPlotPyStack
octolytics-dimension-repository_id671159499
octolytics-dimension-repository_nwoPlotPyStack/PlotPy
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id671159499
octolytics-dimension-repository_network_root_nwoPlotPyStack/PlotPy
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release10c5e2f2307495b2750073db87e9a5d3356a924f
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/PlotPyStack/PlotPy/issues/46#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPlotPyStack%2FPlotPy%2Fissues%2F46
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPlotPyStack%2FPlotPy%2Fissues%2F46
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=PlotPyStack%2FPlotPy
Reloadhttps://github.com/PlotPyStack/PlotPy/issues/46
Reloadhttps://github.com/PlotPyStack/PlotPy/issues/46
Reloadhttps://github.com/PlotPyStack/PlotPy/issues/46
PlotPyStack https://github.com/PlotPyStack
PlotPyhttps://github.com/PlotPyStack/PlotPy
Notifications https://github.com/login?return_to=%2FPlotPyStack%2FPlotPy
Fork 4 https://github.com/login?return_to=%2FPlotPyStack%2FPlotPy
Star 42 https://github.com/login?return_to=%2FPlotPyStack%2FPlotPy
Code https://github.com/PlotPyStack/PlotPy
Issues 2 https://github.com/PlotPyStack/PlotPy/issues
Pull requests 0 https://github.com/PlotPyStack/PlotPy/pulls
Actions https://github.com/PlotPyStack/PlotPy/actions
Projects 0 https://github.com/PlotPyStack/PlotPy/projects
Security 0 https://github.com/PlotPyStack/PlotPy/security
Insights https://github.com/PlotPyStack/PlotPy/pulse
Code https://github.com/PlotPyStack/PlotPy
Issues https://github.com/PlotPyStack/PlotPy/issues
Pull requests https://github.com/PlotPyStack/PlotPy/pulls
Actions https://github.com/PlotPyStack/PlotPy/actions
Projects https://github.com/PlotPyStack/PlotPy/projects
Security https://github.com/PlotPyStack/PlotPy/security
Insights https://github.com/PlotPyStack/PlotPy/pulse
New issuehttps://github.com/login?return_to=https://github.com/PlotPyStack/PlotPy/issues/46
New issuehttps://github.com/login?return_to=https://github.com/PlotPyStack/PlotPy/issues/46
Contrast adjustment with 'eliminate outliers' failed for float images with high dynamic rangehttps://github.com/PlotPyStack/PlotPy/issues/46#top
bugSomething isn't workinghttps://github.com/PlotPyStack/PlotPy/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com/PierreRaybaut
https://github.com/PierreRaybaut
PierreRaybauthttps://github.com/PierreRaybaut
on Jul 2, 2025https://github.com/PlotPyStack/PlotPy/issues/46#issue-3196054750
bugSomething isn't workinghttps://github.com/PlotPyStack/PlotPy/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.