benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 57dd239b-e1b0-56e1-bd43-b928e591bd15

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import cv2
import matplotlib.pyplot as plt

def task_func(image_path, kernel_size):
    """
    Applies a blur effect to an image using a specified kernel size, then visualizes both the original and blurred images side by side.

    Parameters:
    - image_path (str): The file path to the input image.
    - kernel_size (int): The size of the kernel used for blurring. Must be a positive integer.

    Returns:
    - tuple: A tuple containing a numpy.ndarray of the blurred image, and two matplotlib.axes.Axes objects for the plots of the original and blurred images.

    Raises:
    - FileNotFoundError: If the specified image file does not exist.
    - ValueError: If kernel_size is not a positive integer.

    Requirements:
    - opencv-python (cv2) for image processing.
    - matplotlib.pyplot for plotting images.

    Example:
    >>> dummy_img_path = "image.jpg"
    >>> np.random.seed(42)
    >>> dummy_img = np.random.randint(0, 255, (20, 20, 3), dtype=np.uint8)
    >>> cv2.imwrite(dummy_img_path, dummy_img)
    True
    >>> blurred_img, ax_original, ax_blurred = task_func('image.jpg', 5) # The function returns the blurred image array, and axes objects with titles 'Original' and 'Blurred' for the original and blurred images, respectively.
    >>> os.remove(dummy_img_path)
    """

instruct prompt

Applies a blur effect to an image using a specified kernel size, then visualizes both the original and blurred images side by side.
The function should raise the exception for: FileNotFoundError: If the specified image file does not exist. ValueError: If kernel_size is not a positive integer.
The function should output with:
    tuple: A tuple containing a numpy.ndarray of the blurred image, and two matplotlib.axes.Axes objects for the plots of the original and blurred images.
You should write self-contained code starting with:

Code

import cv2
import matplotlib.pyplot as plt
def task_func(image_path, kernel_size):

code prompt

Code

import cv2
import matplotlib.pyplot as plt
def task_func(image_path, kernel_size):

entry point

task_func

libs

  • matplotlib
  • cv2

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import