This python script uses "itk" library to apply a filter to an image. Then, it is possible to see the two images (the original image and the filtered one) with the "vtk" library.
Before you start, you have to clone the git repository with this command :
git clone https://github.com/FlorianDAVAUX/First_Exercise.git
Then, you have ton install the two librairies :
pip3 install itk vtk
To run the code you have to write this line in the terminal :
python3 exercise.py input_image output_image radius
- input_image : the path to the image you want to filter
- output_image : the path to save the image filtered
- radius : the radius if the median filter
- First, the script read the image with "itk.imread()"
- Then, it applies the median filter with "itk.median_image_filter()"
- Finally, it saves the new image with "itk.imwrite()"
Thanks to the function "display_images(image_path1, image_path2)" with the two images path arguments
- First, it reads the two images with "vtkJPEGReader()"
- Then, it creates image viewers with "vtk.vtkImageViewer2()" to visualise the image
- It sets up the rendering window and interactor with "vtk.vtkRenderWindow()" and "vtk.vtkRenderWindowInteractor()"
- Then, set the interactor style for interacting with the image viewer
- Set the position of the second image viewer in the same window
- Render both images
- Start the interactor and display the images