Created
August 3, 2023 08:03
-
-
Save M0nteCarl0/cb9106454bb019c6eea8b96ec8cc21af to your computer and use it in GitHub Desktop.
DQE_MTF example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from scipy.fft import fft2 | |
from scipy.ndimage import sobel, gaussian_filter | |
from PIL import Image | |
def compute_dqe(image_path): | |
# Load the X-ray image | |
image = Image.open(image_path).convert("L") | |
image = np.array(image) | |
# Apply preprocessing steps if necessary | |
# e.g., denoising, contrast adjustment, histogram equalization | |
# Compute the noise power spectrum (NPS) | |
image_fft = fft2(image) | |
image_power_spectrum = np.abs(image_fft) ** 2 | |
nps = np.mean(image_power_spectrum) | |
# Compute the modulation transfer function (MTF) | |
edges = sobel(image) | |
edges_fft = fft2(edges) | |
mtf = np.abs(edges_fft) / np.abs(image_fft) | |
# Compute the Detective Quantum Efficiency (DQE) | |
dqe = (mtf ** 2) / nps | |
return dqe | |
# Example usage | |
image_path = "path/to/your/xray_image.jpg" | |
dqe = compute_dqe(image_path) | |
print("DQE:", dqe) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment