MCPcopy Create free account
hub / github.com/InternRobotics/G2VLM / disk_blur

Function disk_blur

eval_code/recons/models/moge/utils/geometry_numpy.py:329–353  ·  view source on GitHub ↗

Apply disk blur to an image using FFT convolution. Args: image (np.ndarray): Input image, can be grayscale or color. radius (int): Blur radius (in pixels). Returns: np.ndarray: Blurred image.

(image: np.ndarray, radius: int)

Source from the content-addressed store, hash-verified

327
328
329def disk_blur(image: np.ndarray, radius: int) -> np.ndarray:
330 """
331 Apply disk blur to an image using FFT convolution.
332
333 Args:
334 image (np.ndarray): Input image, can be grayscale or color.
335 radius (int): Blur radius (in pixels).
336
337 Returns:
338 np.ndarray: Blurred image.
339 """
340 if radius == 0:
341 return image
342 kernel = disk_kernel(radius)
343 if image.ndim == 2:
344 blurred = fftconvolve(image, kernel, mode='same')
345 elif image.ndim == 3:
346 channels = []
347 for i in range(image.shape[2]):
348 blurred_channel = fftconvolve(image[..., i], kernel, mode='same')
349 channels.append(blurred_channel)
350 blurred = np.stack(channels, axis=-1)
351 else:
352 raise ValueError("Image must be 2D or 3D.")
353 return blurred
354
355
356def depth_of_field(

Callers 1

depth_of_fieldFunction · 0.85

Calls 1

disk_kernelFunction · 0.85

Tested by

no test coverage detected