Image Histogram Analyzer (java, written by Gemini Code Assist)
envgap__gemini__java-t1-21
Written by a coding agent; not on GitHubWritten 2026-03-02
01 / FAILURE SIGNATURE
As the study recorded it
Unclosed string literal
Not a benchmark task.
- Its repair changed source code, so it is not an environment task.
02 / ENVIRONMENT RECIPE
- Base commit
Not freshly verified- Manifest
pom.xml- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / TASK AND FAILURE
gemini/java-t1 #21 · read the task the agent was given
Gemini Code Assist wrote this java project from the task below. It does not run on a clean Ubuntu 22.04 machine as written. Task given to the agent: TASK: Image Histogram Analyzer Write a program that computes and analyzes color histograms of images, providing statistical analysis of color distribution, channel comparisons, and similarity scoring between images. FUNCTIONAL REQUIREMENTS: - Accept an image file path as a command-line argument - Compute per-channel histograms (Red, Green, Blue) with 256 bins each, plus a luminance/grayscale histogram - Calculate statistics for each channel: mean intensity, median, standard deviation, skewness, dominant intensity ranges, and dynamic range (difference between darkest and brightest used values) - Detect if an image is overexposed (high mean, clipped highlights), underexposed (low mean, clipped shadows), or low contrast (narrow histogram spread) - Support histogram comparison between two images via --compare flag: compute correlation, chi-squared distance, intersection, and Bhattacharyya distance between their histograms - Support cumulative histogram computation for each channel via --cumulative flag - Generate a histogram data output as a CSV file with columns (bin, red_count, green_count, blue_count, luminance_count) via --export flag - Support analyzing specific regions of an image via --crop flag (x,y,width,height) - Print a text-based summary to console: per-channel statistics, exposure assessment, contrast assessment, and color balance analysis - Save the full analysis as JSON with --output flag (default: histogram_analysis.json) - Support batch analysis of multiple images via --batch flag with a summary comparison table - If no input is given, generate three sample images (one overexposed, one underexposed, one well-balanced), analyze each, and display comparative results - Handle errors: unsupported image formats, corrupted files, grayscale images (single-channel analysis) Create a complete Java project for a clean Ubuntu 22.04 machine with only JDK 17+ installed. Include: - Source code - pom.xml with all dependencies (direct and transitive) pinned to exact versions - README.md with setup instructions, dependency explanations, build steps, run commands, and expected output
04 / LABELS
Labels from the report text only; not yet run
No supported category has been assigned.
Label rules and the text that matched
[]
05 / FILES
The project as the agent wrote it
3 files, exactly as written, before any repair.
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.image</groupId>
<artifactId>histogram-analyzer</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.image.HistogramAnalyzer</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
README.md
# Image Histogram Analyzer (Java) A tool for computing color histograms from images using Java's ImageIO. ## Setup Instructions 1. Ensure JDK 17+ and Maven are installed. 2. Build the project: ```bash mvn clean package ``` ## Run Commands - **Analyze Image**: ```bash java -jar target/histogram-analyzer-1.0-SNAPSHOT.jar photo.jpg ```
src/main/java/com/image/HistogramAnalyzer.java
package com.image;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
public class HistogramAnalyzer {
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Usage: java -jar analyzer.jar <image_path>");
return;
}
try {
File file = new File(args[0]);
BufferedImage image = ImageIO.read(file);
if (image == null) {
System.err.println("Error: Could not read image.");
return;
}
int[] redHist = new int[256];
int[] greenHist = new int[256];
int[] blueHist = new int[256];
for (int x = 0; x < image.getWidth(); x++) {
for (int y = 0; y < image.getHeight(); y++) {
int rgb = image.getRGB(x, y);
redHist[(rgb >> 16) & 0xFF]++;
greenHist[(rgb >> 8) & 0xFF]++;
blueHist[rgb & 0xFF]++;
}
}
System.out.println("--- Histogram Analysis for " + args[0] + " ---");
printStats("Red", redHist, image.getWidth() * image.getHeight());
printStats("Green", greenHist, image.getWidth() * image.getHeight());
printStats("Blue", blueHist, image.getWidth() * image.getHeight());
} catch (IOException e) {
System.err.println("IO Error: " + e.getMessage());
}
}
private static void printStats(String name, int[] hist, int totalPixels) {
double sum = 0;
for (int i = 0; i < 256; i++) {
sum += i * hist[i];
}
double mean = sum / totalPixels;
System.out.printf("%s Mean Intensity: %.2f
", name, mean);
}
}