I'm fairly well versed in Java syntax and logic, but I'm not incredibly experienced with any sort of useful programming or app development (Meaning I've taken AP CS 1 and did well). I'm trying to get into program development, so as a basic practice problem I am trying to make a program that measures the radius of a white circle on a black background and prints the result to console. Not only is the program not working, the output seems more like a string than an int. Any help is appreciated. The program is composed of two classes, the main, in which the static main method is held, and the RadiusFinder, which holds the methods which do the actual computation. These, as well as the picture I am attempting to analyze, are posted below. The console simply prints 091-91.
[B][ATTACH=CONFIG]3461[/ATTACH][/B] [B]Main Class:[/B] import java.awt.*; import java.awt.Color; import java.awt.Image; import java.awt.image.BufferedImage; public class Main { public static void main(String[] args) { BufferedImage img = null; RadiusFinder test = new RadiusFinder(img); test.pictureSet(); System.out.println(test.radius()); } } [B]RadiusFinder:[/B] import java.awt.Color; import java.awt.Image; import java.awt.image.BufferedImage; import java.io.File; import javax.imageio.ImageIO; public class RadiusFinder { File picture; BufferedImage img = null; int width; int height; int greatestY; int leastY; int greatestX; int leastX; public void pictureSet() { try { picture = new File("C:\\Users\\Matthew\\Pictures\\Camera Roll\\Untitled.jpg"); img = ImageIO.read(picture); }catch(Exception e) { System.out.println(e); } } public RadiusFinder(BufferedImage pic) { pic = img; } public void verticalEdgeFinder() { boolean isLeast = false; boolean isGreatest = false; width = img.getWidth(); height = img.getHeight(); //--------------Used for finding the greatest y value that a white pixel occurs at------ for(int i = height - 1; i < 0 && !isGreatest; i--) { for(int z = 0; z < width && !isGreatest; z++) { Color pixel = new Color(img.getRGB(z, i)); int red = pixel.getRed(); int blue = pixel.getBlue(); int green = pixel.getGreen(); if(red == 255 && blue == 255 && green == 255) { isGreatest = true; greatestY = i; System.out.print(greatestY); } } } //--------------Used for finding the lowest y value that a white pixel occurs at------ for(int i = 0; i < height - 1 && !isLeast; i++) { for(int z = 0; z < width && !isLeast; z++) { Color pixel = new Color(img.getRGB(z, i)); int red = pixel.getRed(); int blue = pixel.getBlue(); int green = pixel.getGreen(); if(red == 255 && blue == 255 && green == 255) { isLeast = true; leastY = i; System.out.print(leastY); } } } } public void horizontalEdgeFinder() { boolean isLeast = false; boolean isGreatest = false; width = img.getWidth(); height = img.getHeight(); for(int i = width - 1; i < 0 && !isGreatest; i--) { for(int z = 0; z < height && !isGreatest; z++) { Color pixel = new Color(img.getRGB(i, z)); int red = pixel.getRed(); int blue = pixel.getBlue(); int green = pixel.getGreen(); if(red == 255 && blue == 255 && green == 255) { isGreatest = true; greatestX = i; System.out.print(greatestX); } } } for(int i = 0; i < width - 1 && !isLeast; i++) { for(int z = 0; z < height && !isLeast; z++) { Color pixel = new Color(img.getRGB(i, z)); int red = pixel.getRed(); int blue = pixel.getBlue(); int green = pixel.getGreen(); if(red == 255 && blue == 255 && green == 255) { isLeast = true; leastX = i; System.out.print(leastY); } } } } public int radius() { pictureSet(); horizontalEdgeFinder(); verticalEdgeFinder(); int rad; if(greatestX-leastX > greatestY - leastY) { rad = greatestX- leastX; }else { rad = greatestY-leastY; } return rad; } }