What is the best way to get the pixel brightness

I have a gray-scale .png image. The pixel brightness is used to communicate the information that i need in my application. Note that i do not show this image in my application, the png file is only used to communicate data. Since this data is being collected as an image at the source we are using a png file to pass around this data. The code is given below
JarEntry entry = m_jarFile.getJarEntry("imageFile.png");
InputStream stream = m_jarFile.getInputStream(entry);
BufferedImage image =  ImageIO.read(overlayImageFileStream);
int cols = overlayImage.getWidth();
int rows = overlayImage.getHeight();
short[][] m_pixelBrightnessValues = new short[cols][rows];
for (int i=0; i<cols; i++) {
     for (int j=0; j<rows; j++) {
          /** BEGIN: Takes too much time */
          int rgb = overlayImage.getRGB(i, j);
          // convert to HSB values.
          int red = (rgb>>16)&0xFF;
          int green = (rgb>>8)&0xFF;
          int blue = rgb&0xFF;
          float[] inputHSB = new float[3];
          inputHSB = Color.RGBtoHSB(red, green, blue, inputHSB);
          /** END: Takes too much time */
          float brightness = inputHSB[2];
          m_pixelBrightnessValues[i][j]= (short)Math.round(brightness * MAX_BRIGHTNESS_VALUE);
}Some portion of the code above takes too much time. I have been tinkering with the following approaches:
1). I can parse the png file myself and extract the brightness information thus bypassing the creation of the BufferedImage altogether.
2). I can continue to create BufferedImage but find out a way to grab brightness directly from the buffered image.
I prefer option 2, since option 1 will require that I figure out png format and then write custom png parsing logic. I have explored all the methods of BufferedImage and it seems there is no way of getting the HSB directly, the only thing readily availabe is RGB values.
I would really appreciate any pointers (e.g. is there something in the Raster that can let me access the brightness data directly ?)
-kashif

I have a gray-scale .png image. The pixel brightness
is used to communicate the information that i need in
my application. Note that i do not show this image in
my application, the png file is only used to
communicate data. Since this data is being collected
as an image at the source we are using a png file to
pass around this data. The code is given below<snip>
>
Some portion of the code above takes too much time. I
have been tinkering with the following approaches:
1). I can parse the png file myself and extract the
brightness information thus bypassing the creation of
the BufferedImage altogether.
2). I can continue to create BufferedImage but find
out a way to grab brightness directly from the
buffered image.
I prefer option 2, since option 1 will require that I
figure out png format and then write custom png
parsing logic. I have explored all the methods of
BufferedImage and it seems there is no way of getting
the HSB directly, the only thing readily availabe is
RGB values.
I would really appreciate any pointers (e.g. is there
something in the Raster that can let me access the
brightness data directly ?)For a greyscale image, the R G abd B values are all the same, and the brightess is simply that value divided by the maximum value. You could create a brightness map in advance which is simply a 256 element array that maps an RGB value to a brightness:
        short[] brightnessMap = new short[256];
        for (int i = 0; i < 256; i++) {
            brightnessMap[i] = (short)(i/255.0f * MAX_BRIGHTNESS_VALUE);
        }Various experiments I performed using PixelGrabber, Raster and such didn't seem to speed things up more than 25% on a 1280 x 1024 image. Times went from around 400 milliseconds to 300.

Similar Messages

  • Policy and best way to get dead pixels fixed.

    I have an iPhone 4 and I have 1 or 2 dead pixels surrounded by about 20 dark pixels. I was wondering if the default warranty would cover this or if I'm stuck with it. Overall the dead pixel isn't that noticeable but the dark cloud around it is really annoying. Thanks for any help you cann offer.

    Hi,
    Don't know about the cost... but here is the Link to the Apple Store in Brisbane...
    http://www.apple.com/au/retail/chermside/
    You can Call them and/or Make an appointment at the Genius Bar and they will advise you...
    Cheers,

  • HT1349 I lost/had my iPhone stolen. Tried using Find My iPhone and it's offline. It was set up. What do I do now? Do I report it stolen? What is the best way in getting back my iPhone if any? Thank you in advance.

    Tried using Find My iPhone and it's offline. It (Find my iPhone) was set up. What do I do now? Do I report it stolen? What is the best way in getting back my iPhone if any? Thank you in advance.

    Find My iPhone is good for misplaced iPhone but not good for thief and it was never meant to be.
    You chance of getting it back is very small.
    There are a few things you can try.
    Try remote lock/wipe your iPhone through Find My iPhone.
    https://www.icloud.com
    You can report to the police, cell carrier (expensive cell charges for international calls, roaming etc)
    Change all the passwords used in iPhone: Apple ID, E-mail, Bank Account ....
    http://support.apple.com/kb/HT2526

  • I recently added my old mac hard drive to a new macbook with an SSD as my main OSX drive.  I am having trouble with permissions in viewing my old hard drive.  What is the best way to get complete access to my old hd installed in my new Macbook?

    I recently added my old mac hard drive to a new macbook with an SSD as my main OSX drive. I am having trouble with permissions in viewing my old hard drive, when I save a permission when I reboot the full access is changed again .  What is the best way to get complete access to my old hd installed in my new Macbook?

    Open the Get Info window for the old drive. Click the Lock icon on the bottom of that window and type in your password. In the permissions area click the Plus sign ( + ) and Add your Username to it and set it to Read & Write. Close that window. you should now have full access to all the files.

  • What is the BEST way to get my macbook with lion on it, to communicate with my Canon 40D camera?

    What is the BEST way to get my macbook with lion on it, to communicate with my Canon 40D camera? It says the utility disk is a PowerPC app and that is no longer supported. What do I do now? I can't upload photos from my camera.

    Also, I had the same problem happen when I tried to install an older version of Corel Painter. Are Macbook Pro users just NOT supposed to be able to use their laptops for the purposes they are best designed for?
    -Frustrated new Mac user

  • Iphone 4s coming friday, what is the best way to get the notes content from iphone 4 to 4s without doing a restore? i want the new phone to be totally new but not sure how to get notes content across.

    What is the best way to get the notes content from iphone 4 to 4s without doing a restore? i want the new phone to be totally new but not sure how to get notes content across. If I do a restore as I have when previously from one iphone to another it has shown (in settings, usage) the cumulative usage from previous phones so all the hours of calls on all previous iphones will be displayed even though its brand new. Anyone know how I can get my notes (from standard iphone notes app) to my new iphone 4s without restoring from previous iphone 4. Thanks for any help offered.

    First, if you haven't updated to iTunes 10.5, please update now as you will need it for the iPhone 4S and iOS 5.
    Once you're done installing iTunes 10.5, open it. Connect your iPhone to iTunes using the USB cable. Once your iPhone pops up right click on it. For example: an iPhone will appear and it will say "Ryan's iPhone."
    Right click on it and select "Backup" from the dropdown menu. It will start backing up. This should backup your notes.
    Please tell me if you have any problems with backing up.
    Once you backup and get your iPhone 4S, you must follow these steps. If you don't follow these steps, you will not be able to get your notes on your new iPhone 4S.
    Open up iTunes again then right click on your device (iPhone 4S). Once you do you will see a dropdown menu. It will say "Restore from Backup..." Select this and it'll ask for a backup, select it from the dropdown menu. For example "Ryan's iPhone - October 12, 2011." Pick that and it will restore to your backup. Do this when you get your iPhone 4S so you will not lose anything. Even though you're restoring, you're getting back, since you're getting the previous settings, notes, contacts, mail and other settings from your old iPhone. You'll still have Siri though! So, restore when you first get it. Also frequently backup your device, as it will be worth it. You can restore from a backup if something goes wrong or save your data for a future update.
    Once you do that, you should have your notes on your new iPhone 4S and iOS 5.
    Please tell me if you need any help.
    I hoped I answered your questions and solved your problem!

  • What is the best way to get a copy of Final Cut 7?  I don't see it on Apple's site anymore and I was told I needed to get ahold of Apple's Pro Divison?

    What's the best way to get a copy of Final Cut 7?

    Amazon.
    Apple stoped selling it officially 20 months ago.

  • HT4260 I have an AirPort Extreme and a linksys router. What is the best way to get 6-8 wired connections with ac speeds?

    I have an AirPort Extreme and a linksys router. What is the best way to get 6-8 wired connections with ac speeds?
    Appreciate your assistance.

    The answer depends on whether the AirPort Extreme is your main router....or...the Linksys device is your main router.
    In either case, the two devices must connect together using a wired Ethernet connection using CAT5e or CAT6 cabling.
    Any version of the AirPort Extreme produced within the last 5 years will have Gigabit Ethernet ports. In order to get the same speeds from the Linksys router, it will also need to be Gigabit Ethernet capable.
    If you need additional Ethernet ports, you will need to add a Gigabit Ethernet switch to either the AirPort Extreme or Linksys router.
    It is assumed that your other devices connecting to the AirPort Extreme and Linksys router will also have Gigabit Ethernet capability.
    Not sure why you mention "ac" speeds in your post. This relates to wireless connections, not wired.

  • I bought CS6 extended yesterday (yes i did). I have CS4 and lots of photo's in bridge (tagged with keywords). What is the best way to get my photos from bridge cs4 to cs6? Is there a guideline how to go about so I don't loose any of my photos/keywords? Wh

    I bought CS6 extended yesterday (yes i did). I have CS4 and lots of photo's in bridge (tagged with keywords). What is the best way to get my photos from bridge cs4 to cs6? Is there a guideline how to go about: so I don't loose any of my photos/keywords? Who can help?

    The Bridge General Discussion can give you the specifics of transferring your information over to Bridge CS6.

  • When I'm done with my fcp sequence, whats the best way to get it to dvd?

    When I'm done with my fcp sequence, whats the best way to get it to dvd?

    The advice to go to Compressor left out the part that you may want to convert your audio to AC3 becaus ethe MPEG2 bitrate is probably too high for DVD specs.
    This method is in the DVDSP manual and it's in the Compressor manual, both difficult to locate, but easily searchable.
    Here's what I'd do: Export the timeline form FCP in the native sequence settings, self-contained. Bring that self-contained movie into DVDSP and let DVDSP handle the transcode.
    The advice to go to iDVD is even easier.
    bogiesan

  • Whats the best way to get dvd onto 5800

    Peoples,
    I'm strugglin to get DVD onto my noka 5800. It's not obvious in the user manual and looking around the web i need to 'convert' it to the fim on.
    Please does anybody have an easy, fool proof way of doing this??????
    Message Edited by blueleaches on 21-Aug-2009 06:02 PM

    If its possible there should be some walkthrough's on google. 
    http://www.lmgtfy.com/?q=whats+the+best+way+to+get+dvd+onto+5800 

  • Whats the best way to get a big text file in a CLOB variable?

    Hi,
    I have a very premitive type of question.
    I have a big text file, say 30 MB, in a Unix directory (Solaris). I want to get the whole text of that file in a CLOB variable.
    I saw the procedure dbms_lob.loadfromfile/loadclobfromfile. In both these cases, according to the documentation, the target where is collect the data will be a BLOB and not a CLOB. So, I have to convert that blob into a clob.
    If I want to avoid all this conversion process, whats the best way to get a text from a file into a CLOB variable?
    Please suggest.
    Regards

    In addition, LoadFromFile is overloaded to handle both BLOB and CLOB:
    PROCEDURE LOADFROMFILE
    Argument Name                  Type                    In/Out Default?
    DEST_LOB                       BLOB                    IN/OUT
    SRC_LOB                        BINARY FILE LOB         IN
    AMOUNT                         NUMBER(38)              IN
    DEST_OFFSET                    NUMBER(38)              IN     DEFAULT
    SRC_OFFSET                     NUMBER(38)              IN     DEFAULT
    <BR>
    PROCEDURE LOADFROMFILE
    Argument Name                  Type                    In/Out Default?
    DEST_LOB                       CLOB                    IN/OUT
    SRC_LOB                        BINARY FILE LOB         IN
    AMOUNT                         NUMBER(38)              IN
    DEST_OFFSET                    NUMBER(38)              IN     DEFAULT
    SRC_OFFSET                     NUMBER(38)              IN     DEFAULT

  • Whats the best way to get the server name in a servlet deployed to a cluster?

              Hi,
              I have a servlet in a web application that is deployed to a cluster, just
              wondering what is the best way to get the name of the node that the server is
              running on at run time??
              Thanks
              

              Please try to modify the following code and test for your purpose: (check Weblogic
              class document for detail)
              import javax.naming.*;
              import weblogic.jndi.*;
              import weblogic.management.*;
              import weblogic.management.configuration.*;
              import weblogic.management.runtime.*;
              MBeanHome home = null;
                   try{
                        //The Environment class represents the properties used to create
                             //an initial Context. DEfault constructor constructs an Environment
                             //with default properties, that is, with a WebLogic initial context.
                             //If unset, the properties for principal and credentials default to
                             //guest/guest, and the provider URL defaults to "t3://localhost:7001".
                             Environment env = new Environment();
                             //Sets the Context.PROVIDER_URL property value to the value of
                             //the argument url.
                             if(admin_url!=null){
                                  env.setProviderUrl(admin_url);
                                  //Sets the Context.SECURITY_PRINCIPAL property to the value of
                                  //the argument principal.
                                  env.setSecurityPrincipal(username);
                                  //Sets the value of the Context.SECURITY_CREDENTIAL property to
                                  //the value of the argument cedentials
                                  env.setSecurityCredentials(password);
                                  //Returns an initial context based on the properties in an Environment.
                                  ctx = env.getInitialContext();
                             }else ctx = new InitialContext();
                             home = (MBeanHome) ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);
                             ctx.close(); //free resource
                             // or if looking up a specific MBeanHome
                             //home = (MBeanHome) ctx.lookup(MBeanHome.JNDI_NAME + "." + serverName);
                             DomainMBean dmb = home.getActiveDomain(); //Get Active Domain
                             ServerMBean[] sbeans = dmb.getServers(); //Get all servers
                             if(sbeans!=null){
                                  for(int s1=0; s1<sbeans.length; s1++){
                                       String privip = sbeans[s1].getListenAddress();
                                  sbeans[s1].getName();
                             sbeans[s1].getListenPort();
                                                 WebServerMBean wmb = sbeans[s1].getWebServer();
                   }catch(Exception ex){
              "Gao Jun" <[email protected]> wrote:
              >Is there any sample code? Thanks
              >
              >Best Regards,
              >Jun Gao
              >
              >"Xiang Rao" <[email protected]> wrote in message
              >news:[email protected]...
              >>
              >> Sure. You can use the Weblogic management APIs to query ServerBean.
              >>
              >>
              >> "Me" <[email protected]> wrote:
              >> >
              >> >Thanks for your reply, i was hoping to find a better way for example
              >> >a class in
              >> >weblogic API.
              >> >
              >> >Thanks
              >> >
              >> >"Xiang Rao" <[email protected]> wrote:
              >> >>
              >> >>Physical: InetAddress.getLocalHost().getHostName()
              >> >>Weblogic: System.getProperty("weblogic.Name");
              >> >>
              >> >>
              >> >>"Me" <[email protected]> wrote:
              >> >>>
              >> >>>Hi,
              >> >>> I have a servlet in a web application that is deployed to a
              >cluster,
              >> >>>just
              >> >>>wondering what is the best way to get the name of the node that
              >the
              >> >>server
              >> >>>is
              >> >>>running on at run time??
              >> >>>
              >> >>>Thanks
              >> >>
              >> >
              >>
              >
              >
              

  • What is the best way to get a time capsule to work with a new network name?

    What is the best way to get a time capsule to work with a new network name?

    Well it seems that you did not explain to us the full story.  Did you change ISP's or something? Why would it not show up anymore?
    What colour is the light on the time-capsule? If it's blinking amber, then you probably need to do a factory-reset. That should get it to show up again in AirPort Utility.

  • What is the best way to get dirty my hand with office 365

    what is the best way to get dirty my hand with office 365
    Anil MCC 2011,ITIL V3,MCSA 2003,MCTS 2010, My Blog : http://messagingschool.wordpress.com

    Hi,
    Just create an evaluation tenate and get your hands Dirty! Or if you are a partner to Microsoft, you can register yourself at
    http://portal.fasttrack.office.com and then you can create sites from there. If you need tenant with data, use
    http://microsoftcie.com and create a tenant, then you will have your own contoso to play with! :) 
    Regards
    Henrik A. Halmstrand
    sharepointrevealed.com
    getspconfig.codeplex.com
    Please click Mark As Answer; if a post solves your problem or Vote As Helpful; if a post has been useful to you.

  • Im having trouble with my ipad mini in regards with the icloud back up notification; if i press "ok" it doesnt dis appear, i couldn open my ipad/turn off because of this notification; whats the best way to get rid of this? please help

    im having trouble with my ipad mini in regards with the icloud back up notification; if i press "ok" it doesnt dis appear, i couldn open my ipad/turn off because of this notification; whats the best way to get rid of this? please help

    Have you tried a soft-reset ? Press and hold both the sleep and home buttons for about 10 to 15 seconds (ignore the red slider if it appears), after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot.

Maybe you are looking for

  • How to Define a Required Prompt at the Universe Level

    Apologies if this has already been covered somewhere... I searched and can't find the topic covered yet. I've been under the impression for a long time that one could configure a Universe such that it would require a prompt on a dimension whenever th

  • Difficulty creating rich text fields with autoresizing text on my mac (Mavericks?)

    I'm a new user so I could be making a simple error, but here goes: I'm trying to make the text fields in a pdf form be rich text with the font autoresizing as needed, but these setting seem not to save when I do this on my new mac desktop. When I ope

  • Player exception..

    Hello everey body.. I have aproblem with recording files.. I make aprogram do the following: 1) browse and an audio file. 2) Then browse again and select a video file. 3) Merge the 2-files to one file. 4) play the merged file at player.. The code for

  • Acrobat Reader 9 installation hangs 1.11%

    Installing from AdbeRdr90_en_US.exe on XP sp2 Install hangs a 1.11% with no cpu message, error message or anything to indicate that it's actually doing anything. Any idea what it's supposed to be doing at this point? Will it ever end and give me a me

  • Load copy of abap table into PI/XI

    Hi, My scenario is as follows: I need to make a lookup in an abap table to determine the receivers of incomming messages. Instead of making a RFC call to the SAP Backend System to request the data each time I would like to move a copy of the abap tab