Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: how to get gray scale value from 16- bit grayscale image

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Thanked 0 Times in 0 Posts

    Default how to get gray scale value from 16- bit grayscale image

    i am getting grayscale value 0 to 255 .which is 8 bits grayscale image .

    int imgwidth = image.getWidth();
    int imgheight = image.getHeight();
    int minThreshold = 0, maxThreshold = 65535;
    //int roiX = p11.x;
    // int roiY = p11.y;
    int roiX = start.x;
    int roiY = start.y;
    double hismin = 0.0,hismax = 0.0;

    short pixelsum = 0;

    int[] histogram = new int[65536];
    short[] pixels = new short[imgwidth * imgheight ];

    Vector pixelValue = new Vector();
    Raster raster = image.getRaster();

    for (int y=roiY; y <(roiY+ height1); y++)
    for (int x=roiX; x < (roiX+width1); x++)
    pixelsum =(short) raster.getSample(x,y,0);
    // short w =(short)(255 - pixelsum);
    // pixelValue.add(w);
    Vector pixelMin = new Vector();
    for(int i = 0; i < pixelValue.size(); i++)
    pixels[i] =(Short)pixelValue.elementAt(i);
    System.out.println("DIV ddspanel under pixel ...----->"+pixels[i]);
    int y = histogram[pixels[i++]&0xffff]++;
    // System.out.println("DIV ddspanel Y ...----->"+y);


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Eastern Florida
    Thanked 2,274 Times in 2,245 Posts

    Default Re: how to get gray scale value from 16- bit grayscale image

    Is this the same question:
    get a pixel value from 16- bit grayscale image
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. get a pixel value from 16- bit grayscale image
    By div111 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 11th, 2013, 01:44 PM
  2. Problems reading a pgm-file (pixel gray map).
    By morob05 in forum File I/O & Other I/O Streams
    Replies: 11
    Last Post: December 25th, 2012, 06:54 AM
  3. Replies: 3
    Last Post: December 21st, 2011, 02:46 PM
  4. Java applet on web showing gray box
    By MyName in forum Java Applets
    Replies: 6
    Last Post: December 2nd, 2011, 02:53 PM
  5. [SOLVED] Scale Numbers from 0.0f to 1.0f
    By techwiz24 in forum Java Theory & Questions
    Replies: 1
    Last Post: September 23rd, 2011, 09:50 PM