I've written a small program that processes black and white images pixel by pixel to determine how how many of the neighbouring pixels are black or white. Then based on this value it changes the colour of the pixel in question.
My problem is that the quality of the output images seems to be significantly lower than the input image. I'm not sure if this is an error with my code or what.
The original images were created using Adobe Illustrator and have a resolution of 1280 x 800 and are 72 DPI.
Here is my code:
//Define PImage variables
PImage source;
PImage destination;
String baseName = "File_";
boolean more;
int z=0;
int t=0;
color white = color(255);
color black = color(0);
void setup()
{
size (1280,800);
do
{
for (z=1; z<9999; z++)
{
//Load source image
more = new File(baseName+nf(z,4)+".png").exists();
I've written a program that grayscales pixels depending on the colour of the neighbouring pixels. I only want to grayscale the pixel if it is white so the first step is to scan through the image pixel by pixel to determine the colour of the pixel. If the pixel is white then the location of the pixel is passed to a method that scans the neighbouring pixels and counts the number of neighbouring white pixels. Based on how many neighbouring pixels are white the colour of the center pixel is then altered.
I want to use this program to process thousands of images (up to 9999), however as the images are processed the program becomes increasingly slow. Do you have any tips as to how I can improve the speed of the image processing?
Thanks
//Define PImage variables
PImage source;
PImage destination;
String baseName = "MRobot_";
boolean more;
int z=1;
int even = 2 ;
void setup()
{
size (1280,800);
}
void draw()
{
do
{
for (z=1; z<9999; z++)
{
//Load source image
source = loadImage(baseName+nf(z,4)+".png");
more = new File(baseName+nf(z,4)+".png").exists();