Assignment 3 by Shamil Shukurov
chemical.py
This python file contains source code for cleaning chemical element images.
Usage: python3 chemical.py <folder_path>
or just python3 chemical.py
folder_path
is path to the folder where noisy chemical element images are saved. If folder path is not specified, default folderpath is 'noisy\chemical'
Program cleans the noisy images in the specified path and saves them in the folder 'cleaned_images\chemical'
This file also contains analysis of different techniques. I have tested different approaches on the first image. Here are the results:
As you may see GaussianBlur is worst and ThresholdedBilateral is best case among tested techniques. Later I continued trying different filters and found final sequence of filters:
# Apply morphological operations separately
vertical_lines = cv2.morphologyEx(bilateral, cv2.MORPH_OPEN, kernel_vertical)
horizontal_lines = cv2.morphologyEx(bilateral, cv2.MORPH_OPEN, kernel_horizontal)
diagonal_lines_1 = cv2.morphologyEx(bilateral, cv2.MORPH_OPEN, kernel_diagonal_1)
diagonal_lines_2 = cv2.morphologyEx(bilateral, cv2.MORPH_OPEN, kernel_diagonal_2)
opening = np.maximum.reduce([vertical_lines, horizontal_lines, diagonal_lines_1, diagonal_lines_2])
# Morphological closing to fill gaps
vertical_lines = cv2.morphologyEx(opening, cv2.MORPH_CLOSE, kernel_vertical)
horizontal_lines = cv2.morphologyEx(opening, cv2.MORPH_CLOSE, kernel_horizontal)
diagonal_lines_1 = cv2.morphologyEx(opening, cv2.MORPH_CLOSE, kernel_diagonal_1)
diagonal_lines_2 = cv2.morphologyEx(opening, cv2.MORPH_CLOSE, kernel_diagonal_2)
closing = np.minimum.reduce([vertical_lines, horizontal_lines, diagonal_lines_1, diagonal_lines_2])
Since chemical elements contains lines (vertical, horizontal, diagonal) I tried to apply opening and closing with line:
speckle.py
This python file contains source code for cleaning images with speckle noise.
Usage: python3 speckle.py <folder_path>
or just python3 speckle.py
folder_path
is path to the folder where noisy images are saved. If folder path is not specified, default folderpath is 'noisy\speckle'
Program cleans the noisy images in the specified path with 2 different approaches and saves them in the folder 'cleaned_images\speckle'
rsna.py
This python file contains source code for task 3.
Usage: python3 rsna.py <image_filepath>
image_filepath
is path to the .dcm
file. Program prints the metadata of the dicom file and plots the pixel array of it.
rsna_updated.py
Usage: python3 rsna_updated.py
Updated version of rsna task. You can now use slider to see different slices of dicom images.