Giter Club home page Giter Club logo

ivanrs297 / endoscopycorruptions Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 4.2 MB

The endoscopycorruptions Python package provides utilities to simulate common image corruptions that might occur during endoscopic procedures. This tool is designed to assist in the development and testing of image processing algorithms intended for endoscopic imagery by introducing realistic corruptions into clean images.

Jupyter Notebook 98.65% Python 1.35%
computer-vision data-science machine-learning medical-imaging python

endoscopycorruptions's Introduction

EndoscopyCorruptions

The endoscopycorruptions Python package provides utilities to simulate common image corruptions that might occur during endoscopic procedures. This tool is designed to assist in the development and testing of image processing algorithms intended for endoscopic imagery by introducing realistic corruptions into clean images. By evaluating algorithms against corrupted images, developers can better understand the robustness and limitations of their solutions.

Alt text

Features

  • Corrupt Function: Applies a specified corruption to an input image.
  • Get Corruption Names: Lists all available corruptions that can be applied.

Getting Started

To use the endoscopycorruptions package, start by importing the necessary functions:

from endoscopycorruptions import corrupt, get_corruption_names
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
import os

Loading an Image

Load your test image using PIL and convert it to a numpy array:

image = np.asarray(Image.open('test_image.png'))
plt.imshow(image)

Preprocessing

If your image includes an alpha channel, you can remove it to ensure compatibility:

if len(image.shape) > 2 and image.shape[2] == 4:
    image = image[:, :, :3]

Listing Available Corruptions

To see what types of corruptions you can apply, use:

get_corruption_names()

Applying Corruptions

You can apply a corruption to your image as follows:

# Example for applying lens distortion with a severity of 5
corrupted_image = corrupt(image, corruption_name='lens_distortion', severity=5)
plt.imshow(corrupted_image)
plt.show()

To apply all available corruptions with varying severities and save the results:

for corruption in get_corruption_names():
    for severity in range(5):
        corrupted = corrupt(image, corruption_name=corruption, severity=severity+1)
        plt.imshow(corrupted)
        plt.axis('off')
        
        folder_path = f"data/{corruption}/"
        if not os.path.exists(folder_path):
            os.makedirs(folder_path)

        plt.savefig(f'{folder_path}/c_{corruption}_sev{severity + 1}.png', bbox_inches='tight')
    print(corruption)

Requirements

This package requires:

  • Python 3.x
  • PIL (Pillow)
  • NumPy
  • Matplotlib
  • An environment that can run Jupyter Notebooks if you wish to use the provided notebook for demonstrations.

The endoscopycorruptions package is an essential tool for researchers and developers working on image processing applications for endoscopy. By facilitating the simulation of realistic image corruptions, it allows for thorough testing and improvement of image analysis algorithms.

Credits to imagecorruptions for the basis of this project.

endoscopycorruptions's People

Contributors

ivanrs297 avatar

Stargazers

Daniel Flores Araiza avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.