<commit_before>// This is a program that edits a picture.

import java.awt.image.*;
import javax.imageio.*;
import java.io.*;

public class TheImage {

	public BufferedImage im = null;
	public int[] packedData = null;
	public int[][][] pixelData = null; 	// Unit be modified.
	public int height = 0;
	public int width = 0;
	public int startX = 0;
	public int startY = 0;

	// Constructor.
	public TheImage (BufferedImage image) {
		im = image;
		height = im.getHeight();
		width = im.getWidth();
		System.out.println(width);
		System.out.println(height);
		packedData = im.getRGB(0, 0, width, height, null, 0, width);
		unpackPixels();
	}

	// Flip the picture horizontally.
	public void flipHorizontal()
	{
		for (int i = 0; i < pixelData.length; i++)
		{
			for (int j = 0; j <= (pixelData[i].length - 1)/2; j++)	// only need to go through half-way point.
			{
				int k = pixelData[i].length - 1 - j;
				int[] temp = pixelData[i][j];
				pixelData[i][j] = pixelData[i][k];
				pixelData[i][k] = temp;
			}
		}

		System.out.println("Flipped Horizontally.");
	}

	// Flip the picture vertically.
	public void flipVertical()
	{
		for (int i = 0; i <= (pixelData.length - 1)/2; i++)	// only need to go through half-way point.
		{
			for (int j = 0; j < pixelData[i].length; j++)
			{
				int k = pixelData.length - 1 - i;
				int[] temp = pixelData[i][j];
				pixelData[i][j] = pixelData[k][j];
				pixelData[k][j] = temp;
			}
		}

		System.out.println("Flipped Vertically.");
	}

	// Invert the color of the picture.
	public void invert()
	{
		for (int i = 0; i < pixelData.length; i++)
		{
			for (int j = 0; j < pixelData[i].length; j++)
			{
				pixelData[i][j][0] = Math.abs (pixelData[i][j][0] - 255);
				pixelData[i][j][1] = Math.abs (pixelData[i][j][1] - 255);
				pixelData[i][j][2] = Math.abs (pixelData[i][j][2] - 255);
			}
		}

		System.out.println("Inverted.");
	}

	public void brighten()
	{
		for (int i = 0; i < pixelData.length; i++)
		{
			for (int j = 0; j < pixelData[i].length; j++)
			{
				pixelData[i][j][0] = (int) (pixelData[i][j][0] * 1.1);
				pixelData[i][j][1] = (int) (pixelData[i][j][1] * 1.1);
				pixelData[i][j][2] = (int) (pixelData[i][j][2] * 1.1);
			}
		}

		System.out.println("Brighten 50%.");
	}

	// Replace the color in a certain range.
	public void replaceColor(int[] oldColor, int[] newColor, int range)
	{
		for (int i = 0; i < pixelData.length; i++)
		{
			for (int j = 0; j < pixelData[i].length; j++)
			{
				// Every channel needs to be in the range.
				if (oldColor[0] - range < pixelData[i][j][0] && pixelData[i][j][0] < oldColor[0] + range && oldColor[1] - range < pixelData[i][j][1] && pixelData[i][j][1] < oldColor[1] + range && oldColor[2] - range < pixelData[i][j][2] && pixelData[i][j][2] < oldColor[2] + range)
				{
					pixelData[i][j] = newColor;
				}
			}
		}<commit_msg>birhten function<commit_after>// This is a program that edits a picture.

import java.awt.image.*;
import javax.imageio.*;
import java.io.*;

public class TheImage {

	public BufferedImage im = null;
	public int[] packedData = null;
	public int[][][] pixelData = null; 	// Unit be modified.
	public int height = 0;
	public int width = 0;
	public int startX = 0;
	public int startY = 0;

	// Constructor.
	public TheImage (BufferedImage image) {
		im = image;
		height = im.getHeight();
		width = im.getWidth();
		System.out.println(width);
		System.out.println(height);
		packedData = im.getRGB(0, 0, width, height, null, 0, width);
		unpackPixels();
	}

	// Flip the picture horizontally.
	public void flipHorizontal()
	{
		for (int i = 0; i < pixelData.length; i++)
		{
			for (int j = 0; j <= (pixelData[i].length - 1)/2; j++)	// only need to go through half-way point.
			{
				int k = pixelData[i].length - 1 - j;
				int[] temp = pixelData[i][j];
				pixelData[i][j] = pixelData[i][k];
				pixelData[i][k] = temp;
			}
		}

		System.out.println("Flipped Horizontally.");
	}

	// Flip the picture vertically.
	public void flipVertical()
	{
		for (int i = 0; i <= (pixelData.length - 1)/2; i++)	// only need to go through half-way point.
		{
			for (int j = 0; j < pixelData[i].length; j++)
			{
				int k = pixelData.length - 1 - i;
				int[] temp = pixelData[i][j];
				pixelData[i][j] = pixelData[k][j];
				pixelData[k][j] = temp;
			}
		}

		System.out.println("Flipped Vertically.");
	}

	// Invert the color of the picture.
	public void invert()
	{
		for (int i = 0; i < pixelData.length; i++)
		{
			for (int j = 0; j < pixelData[i].length; j++)
			{
				pixelData[i][j][0] = Math.abs (pixelData[i][j][0] - 255);
				pixelData[i][j][1] = Math.abs (pixelData[i][j][1] - 255);
				pixelData[i][j][2] = Math.abs (pixelData[i][j][2] - 255);
			}
		}

		System.out.println("Inverted.");
	}

	public void brighten()
	{
		RescaleOp rescaleOp = new RescaleOp(1.2f, 15, null);
		rescaleOp.filter(im, im);

		System.out.println("Brighten.");

		updatePixel();
	}

	private void updatePixel(){
		packedData = im.getRGB(0, 0, width, height, null, 0, width);
		pixelData = null; 	// Release memory first
		unpackPixels();
	}

	// Replace the color in a certain range.
	public void replaceColor(int[] oldColor, int[] newColor, int range)
	{
		for (int i = 0; i < pixelData.length; i++)
		{
			for (int j = 0; j < pixelData[i].length; j++)
			{
				// Every channel needs to be in the range.
				if (oldColor[0] - range < pixelData[i][j][0] && pixelData[i][j][0] < oldColor[0] + range && oldColor[1] - range < pixelData[i][j][1] && pixelData[i][j][1] < oldColor[1] + range && oldColor[2] - range < pixelData[i][j][2] && pixelData[i][j][2] < oldColor[2] + range)
				{
					pixelData[i][j] = newColor;
				}
			}
		}
{'fraction_non_alphanumeric': 0.1871241598868058, 'fraction_numerical': 0.021047046338875133, 'mean_word_length': 3.0625, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3982841', 'n_tokens_mistral': 2470, 'n_tokens_neox': 2155, 'n_words': 564}