benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 073764aa-c010-5800-9133-e2c53c01b76d

Problem

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

complete prompt

import cv2
import os
from matplotlib import pyplot as plt

def task_func(image_path='image.jpg', histogram_path='histogram.png'):
    """
    Read an image, create a histogram of the image pixel intensities, save the histogram as a PNG file, 
    and return the histogram plot object. The function also displays the original image and its histogram.
    The limit to the size of the image depends on the hardware capabilities of the system you are working on. 
    A possible size of an image is 20x20. 

    Parameters:
    - image_path (str): Path to the image file. Defaults to 'image.jpg'.
    - histogram_path (str): Path to save the histogram PNG file. Defaults to 'histogram.png'.

    Returns:
    - matplotlib.axes.Axes: The Axes object of the histogram plot.

    Raises:
    - FileNotFoundError: If the image file does not exist at the specified path.

    Requirements:
    - opencv
    - os
    - matplotlib.pyplot

    Example:
    >>> create_dummy_image('image.jpg')
    >>> histogram_axes = task_func('image.jpg', 'histogram.png')
    >>> os.remove('histogram.png')
    >>> os.remove('image.jpg')
    >>> histogram_axes.title.get_text()
    'Grayscale Histogram'
    """

instruct prompt

Read an image, create a histogram of the image pixel intensities, save the histogram as a PNG file, and return the histogram plot object. The function also displays the original image and its histogram. The limit to the size of the image depends on the hardware capabilities of the system you are working on. A possible size of an image is 20x20.
The function should raise the exception for: FileNotFoundError: If the image file does not exist at the specified path.
The function should output with:
    matplotlib.axes.Axes: The Axes object of the histogram plot.
You should write self-contained code starting with:

Code

import cv2
import os
from matplotlib import pyplot as plt
def task_func(image_path='image.jpg', histogram_path='histogram.png'):

code prompt

Code

import cv2
import os
from matplotlib import pyplot as plt
def task_func(image_path='image.jpg', histogram_path='histogram.png'):

entry point

task_func

libs

  • matplotlib
  • cv2
  • os

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