{"id":18670229,"url":"https://github.com/marieroald/condat_tv","last_synced_at":"2025-11-06T19:30:38.849Z","repository":{"id":62564299,"uuid":"319231710","full_name":"MarieRoald/condat_tv","owner":"MarieRoald","description":"Python wrapper for the fast TV denoising algorithm by Laurent Condat","archived":false,"fork":false,"pushed_at":"2022-02-05T19:18:42.000Z","size":85,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-14T17:07:49.821Z","etag":null,"topics":["compressive-sensing","denoising","regularization","signal-processing","statistics","total-variation"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MarieRoald.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-07T07:00:40.000Z","updated_at":"2022-08-24T07:12:03.000Z","dependencies_parsed_at":"2022-11-03T16:45:37.907Z","dependency_job_id":null,"html_url":"https://github.com/MarieRoald/condat_tv","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarieRoald%2Fcondat_tv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarieRoald%2Fcondat_tv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarieRoald%2Fcondat_tv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarieRoald%2Fcondat_tv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarieRoald","download_url":"https://codeload.github.com/MarieRoald/condat_tv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239502145,"owners_count":19649643,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compressive-sensing","denoising","regularization","signal-processing","statistics","total-variation"],"created_at":"2024-11-07T08:51:34.625Z","updated_at":"2025-11-06T19:30:38.798Z","avatar_url":"https://github.com/MarieRoald.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CondatTV\n\nCython wrapper for the efficient TV denoising algorithm by [Laurent Condat](https://lcondat.github.io/). This wrapper wraps Condats C implementation of the algorithm for use with NumPy.\n\nThe algorithm this code uses is the improved fast total variation algorithm.\nThe original C and MATLAB code is available on the [software page](https://lcondat.github.io/software.html) of Laurent Condat's [webpage](https://lcondat.github.io/).\n\n## Installation instructions\n\nTo install these bindings, you should have a C-compiler installed on your system. Make sure you have [NumPy](https://numpy.org/install/) and [Cython](https://cython.readthedocs.io/en/latest/src/quickstart/install.html) installed beforehand (both packages come with Anaconda by default) and write\n\n```\npip install condat-tv\n```\n\nin your terminal window. In case that does not work, you can install it directly from github by running the command\n\n```\npip install git+https://github.com/yngvem/condat_tv.git\n```\n\n\n## Example of denoising with total variation minimization\n\nThe following example is inspired by the experiments on syntetic data in [[1]](#[1])\n\n\n```python\nimport condat_tv \nimport numpy as np\nimport matplotlib.pyplot as plt\n```\n\n\n### Generate syntetic data\n\n\n```python\nnp.random.seed(0)\n\nN = 500 # number of samples\n\n# Generate a sparse \"derivative\" vector \nsignal_derivative = np.random.standard_normal(N)*4\nfor k in range(N):\n    signal_derivative[k] = signal_derivative[k]*(np.random.uniform(0,1)\u003e0.95)\n    \n# Integrate the sparse derivative vector to obtain a piecewise constant vector\nsignal = np.cumsum(signal_derivative)\n\n# Add noise\nnoisy_signal = signal + np.random.standard_normal(signal.shape)\n```\n\n### Plot the syntetic data\n\n\n```python\nplt.figure(figsize=(12, 4))\n\nplt.plot(signal, label=\"Signal\")\nplt.plot(noisy_signal, label=\"Noisy signal\")\n\nplt.xlim(0, N)\nplt.legend()\nplt.title(\"Plot showing the signal with and without the added noies\")\nplt.show()\n```\n\n\n![png](readme_images/output_5_0.png)\n\n\n### Denoise and visualize the results\n\n\n```python\nplt.figure(figsize=(12, 4))\nplt.plot(signal, label=\"Signal\")\n\nfor reg_strength in [0.5, 2, 8, 32]:\n    # Denoise the signal with total variation minimization\n    denoised_signal = condat_tv.tv_denoise(noisy_signal, reg_strength)\n    \n    # Visualize denoised signal\n    plt.plot(denoised_signal, label=f\"Reg strength: {reg_strength}\")\n    \n    # Calculate and print RMSE\n    RMSE = np.linalg.norm(denoised_signal-signal)/np.sqrt(N)\n    print(f\"Regularisation strength: {reg_strength:.1e}, RMSE: {RMSE:.2e}\")\n    \nplt.xlim(0, N)\nplt.legend(ncol=5)\nplt.title(\"Visualisation of denoising results for different regularisation strengths\")\nplt.show()\n```\n\n    Regularisation strength: 5.0e-01, RMSE: 5.70e-01\n    Regularisation strength: 2.0e+00, RMSE: 3.56e-01\n    Regularisation strength: 8.0e+00, RMSE: 5.89e-01\n    Regularisation strength: 3.2e+01, RMSE: 1.52e+00\n\n\n\n![png](readme_images/output_7_1.png)\n\n\n# References\n\n\u003cp id=\"[1]\"\u003e\n    \u003cb\u003e[1]\u003c/b\u003e Condat L. A direct algorithm for 1-D total variation denoising. IEEE Signal Processing Letters. 2013 Aug 15;20(11):1054-7. \u003ca href=\"https://ieeexplore.ieee.org/abstract/document/6579659\"\u003e(link)\u003c/a\u003e\n\u003cp\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarieroald%2Fcondat_tv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarieroald%2Fcondat_tv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarieroald%2Fcondat_tv/lists"}