def _rs_filter(sinogram, window, listsign, sigma, size, pad): """ Remove stripes using the filtering technique. """ sinogram = np.transpose(sinogram) padded_sino = np.pad(sinogram, ((0, 0), (pad, pad)), mode='reflect') (_, ncol) = padded_sino.shape sinosmooth = np.zeros_like(sinogram) for i, sinolist in enumerate(padded_sino): sinosmooth[i] = np.real( ifft(fft(sinolist * listsign) * window) * listsign)[pad:ncol - pad] sinosharp = sinogram - sinosmooth sinosmooth_cor = median_filter(sinosmooth, (size, 1)) return np.transpose(sinosmooth_cor + sinosharp)
def _rs_filter(sinogram, window, listsign, size, dim, pad): """ Remove stripes using the filtering technique. """ sinogram = np.transpose(sinogram) padded_sino = np.pad(sinogram, ((0, 0), (pad, pad)), mode='reflect') (nrow, ncol) = padded_sino.shape sinosmooth = np.zeros_like(sinogram) for i, sinolist in enumerate(padded_sino): sinosmooth[i] = np.real( ifft(fft(sinolist * listsign) * window) * listsign)[pad:ncol - pad] sinosharp = sinogram - sinosmooth matindex = _create_matindex(nrow, ncol - 2 * pad) sinosmooth_cor = np.transpose( _rs_sort(np.transpose(sinosmooth), size, matindex, dim)) return np.transpose(sinosmooth_cor + sinosharp)
def _remove_stripe_fw(tomo, level, wname, sigma, pad): dx, dy, dz = tomo.shape nx = dx if pad: nx = dx + dx // 8 xshift = int((nx - dx) // 2) num_jobs = tomo.shape[1] for m in range(num_jobs): sli = np.zeros((nx, dz), dtype='float32') sli[xshift:dx + xshift] = tomo[:, m, :] # Wavelet decomposition. cH = [] cV = [] cD = [] for n in range(level): sli, (cHt, cVt, cDt) = pywt.dwt2(sli, wname) cH.append(cHt) cV.append(cVt) cD.append(cDt) # FFT transform of horizontal frequency bands. for n in range(level): # FFT fcV = np.fft.fftshift(fft(cV[n], axis=0, extra_info=num_jobs)) my, mx = fcV.shape # Damping of ring artifact information. y_hat = (np.arange(-my, my, 2, dtype='float32') + 1) / 2 damp = -np.expm1(-np.square(y_hat) / (2 * np.square(sigma))) fcV *= np.transpose(np.tile(damp, (mx, 1))) # Inverse FFT. cV[n] = np.real(ifft(np.fft.ifftshift( fcV), axis=0, extra_info=num_jobs)) # Wavelet reconstruction. for n in range(level)[::-1]: sli = sli[0:cH[n].shape[0], 0:cH[n].shape[1]] sli = pywt.idwt2((sli, (cH[n], cV[n], cD[n])), wname) tomo[:, m, :] = sli[xshift:dx + xshift, 0:dz]
def _remove_stripe_fw(tomo, level, wname, sigma, pad): dx, dy, dz = tomo.shape nx = dx if pad: nx = dx + dx // 8 xshift = int((nx - dx) // 2) num_jobs = tomo.shape[1] for m in range(num_jobs): sli = np.zeros((nx, dz), dtype='float32') sli[xshift:dx + xshift] = tomo[:, m, :] # Wavelet decomposition. cH = [] cV = [] cD = [] for n in range(level): sli, (cHt, cVt, cDt) = pywt.dwt2(sli, wname) cH.append(cHt) cV.append(cVt) cD.append(cDt) # FFT transform of horizontal frequency bands. for n in range(level): # FFT fcV = np.fft.fftshift(fft(cV[n], axis=0, extra_info=num_jobs)) my, mx = fcV.shape # Damping of ring artifact information. y_hat = (np.arange(-my, my, 2, dtype='float32') + 1) / 2 damp = -np.expm1(-np.square(y_hat) / (2 * np.square(sigma))) fcV *= np.transpose(np.tile(damp, (mx, 1))) # Inverse FFT. cV[n] = np.real( ifft(np.fft.ifftshift(fcV), axis=0, extra_info=num_jobs)) # Wavelet reconstruction. for n in range(level)[::-1]: sli = sli[0:cH[n].shape[0], 0:cH[n].shape[1]] sli = pywt.idwt2((sli, (cH[n], cV[n], cD[n])), wname) tomo[:, m, :] = sli[xshift:dx + xshift, 0:dz]