Pengesanan Puncak dalam Tatasusunan 2D
Cabaran:
Mengesan puncak dalam tatasusunan 2D mewakili ukuran tekanan di bawah kaki anjing, untuk menggambarkan subkawasan anatomi.
Penyelesaian:
Penyelesaian praktikal melibatkan penggunaan penapis maksimum tempatan untuk mengenal pasti puncak. Begini caranya:
<code class="python">import numpy as np import matplotlib.pyplot as plt from scipy.ndimage.filters import maximum_filter from scipy.ndimage.morphology import generate_binary_structure, binary_erosion # Define the paw data paw_data = np.loadtxt("paws.txt").reshape(4, 11, 14) # Define the 8-connected neighborhood neighborhood = generate_binary_structure(2, 2) # Function to detect peaks def detect_peaks(image): # Local maximum filter local_max = maximum_filter(image, footprint=neighborhood) == image # Create a mask of the background background = (image == 0) # Erode the background to remove artifacts eroded_background = binary_erosion(background, structure=neighborhood, border_value=1) # Final mask containing only peaks detected_peaks = local_max ^ eroded_background return detected_peaks # Detect peaks for each paw paws = [p.squeeze() for p in np.vsplit(paw_data, 4)] detected_peaks_list = [] for paw in paws: detected_peaks = detect_peaks(paw) detected_peaks_list.append(detected_peaks) # Plot the results fig, axs = plt.subplots(4, 2, figsize=(10, 10)) for i, paw in enumerate(paws): axs[i, 0].imshow(paw) axs[i, 0].set_title("Paw Image") axs[i, 1].imshow(detected_peaks_list[i]) axs[i, 1].set_title("Peak Detection") plt.tight_layout() plt.show()</code>
Pertimbangan:
Atas ialah kandungan terperinci Bagaimanakah penapisan maksimum tempatan boleh digunakan untuk mengenal pasti puncak tekanan dalam tatasusunan 2D yang mewakili kaki anjing?. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!