Figure 1 - image processing pipeline. From left to right: original image, perspective warping, inpainting, noise filtering, colour and contrast adjustment
This repo implements exemplar-based inpainting (Criminisi 2004) on chest x-ray images using OpenCV and NumPy. A small classifier demo and a sample dataset are included under image_processing_files/.
Project received 67/100 (2:1 classification)
- Accuracy 92% - 16/20
- Visual quality - 14/20. Categories:
- −2 pts: Though noise removal has been done to some extent, the images still contain some noise.
- −4 pts: Significant amounts of unwanted artefacts have been introduced as part of the processing applied to the images.
- -0 pts: The contrast, brightness and the colours are visually plausible.
- -0 pts: The images have been successfully dewarped, as visually judged by a human observer.
- Code quality - 5/5
- Code is sufficiently commented / documented.
- The code is structured well and it is clear how different tasks are performed.
- Report - 20/30
- -0 pts: The report outlines and describes the proposed solution.
- -3 pts: The report is not structured very clearly. There are no sections and subsections and this makes following the report a bit difficult.
- -7 pts: The analysis of the results is not thorough enough. Including numerical evaluations and analyses in the form of tables, diagrams, histograms, etc. would have improved the quality of the report.
- Advanced credit - 10/20
- Credit given for the use of contours.
- Credit given for the way inpainting part of the solution is handled.
scripts/main.py— runs the inpainting pipeline over a folder of images.classify.py— optional classifier demo using OpenCV DNN.
src/criminisi_inpainter.py— core Criminisi inpainting implementation (OpenCV-based).
models/— classifier modelclassifier.model— ONNX weights for the classifier demo.
xray_images/— 100 sample images (first 50 healthy, next 50 pneumonia).results/— output folder for processed images (auto-created if missing).
This project uses uv for dependency management. First, install uv if you don't have it:
curl -LsSf https://astral.sh/uv/install.sh | shThen sync the dependencies:
uv syncQuick start – run full pipeline
./run_pipeline.shThis runs the complete pipeline: image inpainting followed by classification of the processed images, and outputs the final accuracy.
Process images only
python3 scripts/main.pyBy default, the images inside xray_images are processed. To specify a different directory of images, from the project root run:
python3 scripts/main.py <path_to_images>Output images are written to results/ with the same filenames as inputs.
- Performance: inpainting is patch-based and can be slow on large images. Consider downscaling inputs or reducing
patch_sizefor quicker runs.
There’s a simple classifier example you can run on the sample images using the included ONNX model and OpenCV’s DNN module:
python3 scripts/classify.py --data best_resultsIt will print a predicted label per image and a final accuracy (first 50 images are labelled healthy, next 50 pneumonia).
- Start partway through a directory: set the
start_fromvariable near the bottom ofscripts/main.pyto the desired starting filename (e.g., "im044-healthy.jpg"). Set toNoneto process all files. - Inpainter options (see
criminisi_inpainter.pyconstructor):patch_size(default 9)verbose=True|False— print timing/progress for inpainting.show_progress=True|False— save intermediate working images intoresults/each iteration.
[1] A. Criminisi, P. Pérez and K. Toyama, "Region filling and object removal by exemplar-based image inpainting," IEEE Transactions on Image Processing, vol. 13, no. 9, pp. 1200-1212, 2004.
[2] I. C. Moura, "inpaint-object-remover" (2021). https://github.com/igorcmoura/inpaint-object-remover (commit dc535f2).
