benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf e72418c7-4429-5a58-8199-294bad97e33c
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import numpy as np
import matplotlib.pyplot as plt
from scipy.ndimage import gaussian_filter
def task_func(image, sigma=2):
"""
Apply a Gaussian filter to a given image and draw the original and filtered images side by side.
Parameters:
- image (numpy.ndarray): The input image to apply the filter on.
- sigma (float, optional): The sigma value for the Gaussian filter. Default is 2.
Returns:
- ax (matplotlib.axes.Axes): Axes object containing the plot. Two plots with titles 'Original' and 'Filtered'.
- filtered_image (numpy.ndarray): The numpy array of pixel values for the filtered image.
Raises:
- ValueError: If sigma is non-positive.
- TypeError: If the input is not a numpy array.
Requirements:
- numpy
- matplotlib.pyplot
- scipy.ndimage
Example:
>>> from skimage import data
>>> ax, filtered_image = task_func(data.coins())
>>> ax[0].get_title() # Checking the title of the first subplot
'Original'
>>> ax[1].get_title() # Checking the title of the second subplot
'Filtered'
"""
instruct prompt
Apply a Gaussian filter to a given image and draw the original and filtered images side by side.
The function should raise the exception for: ValueError: If sigma is non-positive. TypeError: If the input is not a numpy array.
The function should output with:
ax (matplotlib.axes.Axes): Axes object containing the plot. Two plots with titles 'Original' and 'Filtered'.
filtered_image (numpy.ndarray): The numpy array of pixel values for the filtered image.
You should write self-contained code starting with:
Code
import numpy as np
import matplotlib.pyplot as plt
from scipy.ndimage import gaussian_filter
def task_func(image, sigma=2):
code prompt
Code
import numpy as np
import matplotlib.pyplot as plt
from scipy.ndimage import gaussian_filter
def task_func(image, sigma=2):
entry point
task_func
libs
- numpy
- matplotlib
- scipy
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
initial import