CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-imutils

A series of convenience functions to make basic image processing functions such as translation, rotation, resizing, skeletonization, displaying Matplotlib images, sorting contours, detecting edges, and much more easier with OpenCV and both Python 2.7 and Python 3.

91

1.33x
Overview
Eval results
Files

task.mdevals/scenario-8/

Image Visualization Tool

Build a tool that loads images using OpenCV and displays them using Matplotlib for visualization. The tool should handle proper color format conversion to ensure images appear correctly in Matplotlib plots.

Requirements

Create a Python module that provides functionality to:

  1. Load an image from a file path using OpenCV
  2. Convert the loaded image to the appropriate color format for Matplotlib display
  3. Display the image using Matplotlib with a configurable title
  4. Support grayscale images (display them without color conversion)

The solution should handle both color and grayscale images correctly.

Implementation

@generates

API

def visualize_image(image_path, title="Image"):
    """
    Load an image from the given path and display it using Matplotlib.

    Args:
        image_path (str): Path to the image file
        title (str): Title to display above the image (default: "Image")

    Returns:
        None

    Raises:
        FileNotFoundError: If the image file does not exist
    """
    pass

Test Cases

  • Loads a color image (BGR format) from a file and displays it correctly in Matplotlib with proper RGB colors @test
  • Loads a grayscale image and displays it correctly in grayscale @test
  • Raises FileNotFoundError when the image file does not exist @test

Dependencies { .dependencies }

imutils { .dependency }

Provides convenience functions for image processing operations.

opencv-python { .dependency }

Provides computer vision and image processing capabilities.

matplotlib { .dependency }

Provides plotting and visualization support.

Install with Tessl CLI

npx tessl i tessl/pypi-imutils

tile.json