Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi!
I have converted a colored image into black and white. Now I want to perform thinning on that image, but I do not know how to do so. Kindly help me in this regard. I need JAVA source code. Thanks and warm Regards!

My code is as follows:
C#
public static void main(String[] args) 
{
    Image image = null;
    try
    {
        //colored image path
        BufferedImage colored_image = ImageIO.read(new File("D:\\logo.jpg"));
        //getting width and height of image
        double image_width = colored_image.getWidth();
        double image_height = colored_image.getHeight();

        BufferedImage img = colored_image;

        //drawing a new image
        BufferedImage bimg = new BufferedImage((int)image_width, (int)image_height, BufferedImage.TYPE_BYTE_GRAY);
        Graphics2D gg = bimg.createGraphics();
        gg.drawImage(img, 0, 0, img.getWidth(null), img.getHeight(null), null);

        //saving black and white image onto drive
        String temp = "logo in blackAndwhite.jpeg";
        File fi = new File("D:\\ " + temp);
        ImageIO.write(bimg, "jpg", fi);            
    }
    catch (Exception e)
    {
        System.out.println(e);
    }       
 }
Posted
Updated 23-Jun-12 5:02am
v2

1 solution

See here[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900