Skip to content

Commit

Permalink
Piping for spectrogram set up
Browse files Browse the repository at this point in the history
  • Loading branch information
lim185 committed Dec 6, 2024
1 parent b0e1459 commit 1e76eec
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion pipe/pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,29 @@

def image_pipe(imagepath: Path, namepattern: str, stacksize: int)
-> np.ndarray:
images = np.zeros((stacksize, 800,800)
images = np.zeros((stacksize, 800,800))
for i in range(stacksize):
images[i,:,:] = cv.imread(imagepath/namepattern.format(i), -1)

return images

def spectrogram_pipe(specpath: Path, namepattern: str, freq_samples: int)
-> np.ndarray:
"""
Loads spectrograms for each stack iteration from an hdf5 data file.
Args:
specpath (Path): Path to the spectrogram files.
namepattern (str): Name pattern for the spectrogram files.
stacksize (int): Number of spectrograms in the stack.
freq_samples (int): Number of frequency samples in each spectrogram.
Returns:
spectrograms (np.ndarray): Stack of spectrograms (2D array).
"""

with h5py.File(specpath/namepattern.format(i), 'r') as f:
spectrograms = f['spectrogram'][:]

return spectrograms

# EOF

0 comments on commit 1e76eec

Please sign in to comment.