I NEED HELP PLZZZ!!!

Hiiiiiiii....
i'm trying to write a program which converts colored images to gayscale and saves them.The onle problem is that when i convert them they get to be so dark unlike when i try to do it with photoshop..
can anyone help me plzzzz...
i really neeeed someones help.
This is what i have come up with.. plzz if anyone has better solution or can correct mine i'ld be really thankful.
public static void writeImage(String fn, byte[] data, int width, int height)throws FileNotFoundException, IOException {
FileOutputStream fOut = new FileOutputStream(fn);
JPEGImageEncoder jpeg_encode = JPEGCodec.createJPEGEncoder(fOut);
int ints[] = new int[data.length];
for (int i = 0; i< data.length; i++){
ints[i] = 255 << 24 |
(int) (data[i] & 0xff) <<16 |
(int) (data[i] & 0xff) << 8 |
(int) (data[i] & 0xff);
BufferedImage image = new BufferedImage(100,100,
BufferedImage.TYPE_BYTE_GRAY);
image.setRGB(0,0,width,height,ints,0,width);
jpeg_encode.encode(image);
fOut.close();
where data=jpgFile.getBytes();
note:i don't want the images just to look like grayscale i really want them to be grayscale so when i use an if statement like:
if(image.getType() == BufferedImage.TYPE_BYTE_GRAY)it would work.
thanxxxxxxxxxxxxxxxxxxxxxxxxxx

for (int i = 0; i< data.length; i++){
ints[i] = 255 << 24 |I think you can just leave the alpha channel at zero. Anyway...
(int) (data[i] & 0xff) <<16 |
(int) (data[i] & 0xff) << 8 |
(int) (data[i] & 0xff);
}OK, what you're doing here is taking the blue channel and copying it to red and green. The result's grayscale, sure, but it's probably not what you want.
Instead, take the red, green and blue and average them. Then put that averaged value into all 3 channels. Something like...
gray = (int)((
(data[i] & 0xff0000) >>16 |
(data[i] & 0xff00) >>8 |
(data[i] & 0xff) ) /3);
ints[i] = (int) (gray) <<16 |
(int) (gray) << 8 |
(int) (gray);
note:i don't want the images just to look like
grayscale i really want them to be grayscale so when iIf the red green and blue are the same, it's grayscale...
Hope that helps.

Similar Messages

  • Need Help PLzzz

    when i turn my ipod on it makes a ticking noise and the sad face shows up. i tried doing everything on the website but nothing happens. when i get into disk mode i plug it in and it does it all over agian. it doesnt show up on disk mangement eihter. anyone know what to do?

    does that webiste really fix the ipod?

  • Hi i need sum help plzzz, iphone 3gs blackscreen and tryed evrything but wont kick out of dfu mode , much apreicated plz

    hi i need sum help plzzz, iphone 3gs blackscreen and tryed evrything but wont kick out of dfu mode , much apreicated plz, it just happen wen i was restoring  the screen is balck but wen i restore it from itunes it says erorr 1600 and itunes does not reconise the phone , i have tryed eveything bt still no luck , I NEED UR HELP PLZZZ ,its my disabled daughters thank you

    Anyone on this forum can correct me if I am wrong. I am not judging you, but to my knowledge the iTunes error 1600  usually affects products that are  jailbroken. again I am not saying that your iPhone 3GS was jailbroken. my only advise off the top of my head to assist you is to download the recent IOS firmware online. I know it is not the the #1 advised option, but it is the only option you have unless you wish to bring it to the Apple Genius bar and see if they can replace the phone or fix it themselves.

  • NEED HELP!!! with my Micro Photo

    i need help i was having problems with my computer recognizing my Micro Photo so i was in to recovery menu so then i accidentally hit the reload firmware option and now i cant get it to work it only goes onto the Recovery Menu and i cant get the firmware updater to work and i cnat find no files of the firmware itself...but the weird thing is i can access the Micro Photo itself through my computer and browse it but idk wat to do some plzzz help me

    themagooshow,
    You don't need USB2.0 but you will need to have at least Service Pack for your Windows XP and Windows Media Player 0 installed.
    Jason

  • Plz Anyone i need help

    hi,
    i have a question if someone can awnser that i am designing a data warehouse with dimensions and fact table. The current operational data base has four year old data. Two of the dimensions are slowly changing dimension. My question is how do you load the dimension with previous 4 years data and do you start the slowly changing dimension process right from the first row or option 2 you load four years previous data and then implement the slowly changing data. Please im new to data warehouse and stuck in big time plzzz if some one can reply and help me out. either here or email me [email protected]
    Arjumand

    Thank You so much. My question is i have an account table and an account history table in the operational data base. When ever a change is made to the account table a trigger is fired and new row with old valu and a new value is inserted into the account history table in the operational data base but in account history table only that old and new value is inserted not the full detail of an account. I have designed an account dimension from which table would i start loading the table and if i want to also include the changes is that possible. I am new working hard so need help. When we for the first time load the dimension do we load all the previous years data first and then implement slowly changing dimension theory or we just do it after the dimension is loaded and when the new data arrives from that point we implement slowly changing dimension.
    Thank you

  • I need help regarding measurement of "time domain parameters of Heart rate variability" using labview.

    I need help regarding measurement of "time domain parameters of Heart rate variability" using labview.
    I am using Labview 8 ... I  need to develop a software to accquire the ECG data (simulated enironment ) and compute the time domain parameters of Heart rate variability like "SDNN, SDANN...etc". Can some 1 plllzzzz help me out.Plzz help me if u can.Thanx in advance.

    Hi Andy,
      Thanx for responding.  The input is from a text file. SDNN, SDANN,etc are  the timedomain parameters of heart rate variability.
     SDNN: the standard deviation of the NN or RR interval  i.e. the square root of variance.
    SDANN:the standard deviation of the averageNN interval calculated over short periods, usually 5 min,which is an estimate of the changes in heart rate due tocycles longer than 5 min
    SDNN index, the meanof the 5-min standard deviation of the NN intervalcalculated over 24 h,
     RMSSD: the square root ofthe mean squared differences of successive NN intervals
    NN50: the number of interval differences of successiveNN intervals greater than 50 ms, and
    pNN50 the proportionderived by dividing NN50 by the total numberof NN intervals.
    The problem is dat I am a fresher to the world of Labview. I have jus recently started working on it. Can u please suggest me some some idea as soon as possible.
      As i said  I have the ECG data in the form of text files..I need to create sort of GUI to calculate the time domain parmeters....I need help urgently. Plzzz help me if u can. If u have and .vi example to calculate the RR interval plzz send it to me ASAP.
    Thanku

  • HT5312 Every time i try to buy something from the Itunes i cant because i most answer the security question but I don't remember my security question answer help plzzz, note: I can't call the apple support because I live in Saudi Arabi

    Every time i try to buy something from the AppStore  on my iPad or iPhone 4S i cant because i most answer the security question but I don't remember my security question answer, when I try to go change it from my Apple account he ask me the security questions agin and I don't know the answer help plzzz, note: I can't call the apple support because I live in Saudi Arabia

    If you don't see the 'send reset info' button on the page where you can change them then I assume that you don't have a rescue email address (which is not the same thing as an alternate email address) set up on your account. As you won't be able to add one until you can answer 2 of your questions, you will need to contact iTunes Support or Apple to get the questions reset. You could try contacting iTunes Support : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Account Management , and then try Apple ID Account Security

  • Need help to develop Pythagoras theorem-

    Hi i need help to develop proofs 2,3,4
    of pythagoras theorems in java as demonstrations
    These are applets can anyone help me with it or give me an idea of how to go about developing it -
    the site is the following
    http://www.uni-koeln.de/ew-fak/Mathe/Projekte/VisuPro/pythagoras/pythagoras.html
    then double click on the screen to make it start

    Pardon my ASCII art, but I've always liked the following, simple, geometric proof:
         a                   b
    ---------------------------------------+
    |       |                                |
    a|   I   |              II                |
    |       |                                |
    ---------------------------------------+
    |       |                                |
    |       |                                |
    |       |                                |
    |       |                                |
    |       |                                |
    b|  IV   |              III               |
    |       |                                |
    |       |                                |
    |       |                                |
    |       |                                |
    |       |                                |
    |       |                                |
    ---------------------------------------+It almost goes without saying that I+II+III+IV == (a+b)^2, and II == IV == a*b,
    I == a*a and III == b*b, showing that (a+b)^2 == a^2+a*b+a*b+b^2.
    I hope the following sketch makes sense, stand back, ASCII art alert again:     a                   b
    ---------------------------------------+
    |               .             VI         |
    |     .                 .                |a
    | V                               .      |
    |                                        +
    |                                        |
    |   .                                    |
    b|                                     .  |
    |                                        |
    |                  IX                    |
    | .                                      |
    |                                    .   |b
    |                                        |
    +                                        |
    |      .                                 |
    a|               .                  . VII |
    |  VIII                   .              |
    ---------------------------------------+
                     a                    bThe total area equals (a+b)^2 again and equals the sum of the smaller areas:
    (a+b)^2 == V+VI+VII+VIII+IX. Let area IX be c^2 for whatever c may be.
    V+VII == VI+VIII == a*b, so a^2+b^2+2*ab= c^2+2*a*b; IOW a^2+b^2 == c^2
    Given this fundamental result, the others can easily be derived from this one,
    or did I answer a question you didn't ask?
    kind regards,
    Jos

  • I need help to find and open a job app that I exported, was able to fill out and sign and saved and now can't open it? What did I do wrong?

    I need help to find and open a job app that I exported, was able to fill out and sign and saved and now can't open it? What did I do wrong?

    What file format did you export it to?

  • Need help to open audios attached in a PDF file

    Hello
    I just need help. I have ordered a reviewer online that has audios and texts in a pdf file. I was told to download the latest adobe reader on my computer. I have done the same thing on my ipad mini. I am not so technical with regards to these things. Therefore I need help. I can access the audios on my computer but not on my ipad.
    I want to listen to audios with scripts or texts on them so i can listen to them when i am on the go. I was also informed that these files should work in any device. How come the audios doesnt work on my ipad.
    Please help me on what to do.
    Thanks

    Audio and video are not currently support on Adobe Reader. :-<
    You need to buy a PDF reader that supports them. My suggestion is PDF Expert from Readdle ($US 9.99)

  • Need help to open and look for file by name

    Hi,
            Im needing help to open a folder and look for a file (.txt) on this directory by his name ... The user ll type the partial name of file , and i need look for this file on the folder , and delete it ....
    How can i look for the file by his name ?
    Thx =)

    Hi ,
        Sry ,, let me explain again ... I ll set the name of the files in the follow order ... Name_Serial_date_chanel.sxc ..
    The user ll type the serial that he wants delete ...
    I already figured out what i need guys .. thx for the help ^^
    I used List Directory on advanced IO , to list all .. the Name is the same for all ... then i used Name_ concateneted with Serial(typed)* .. this command serial* ll list all serials equal the typed , in my case , ll exist only one , cuz its a count this serial .Then i pass the path to the delete , and its done !
    Thx ^^

  • I need help, my ipod touch is not recognized by windows as a harddisk

    i need help, my ipod touch is not recognized by windows like a memory card or a harddisk.
    i would like to transfer the files from pc to my ipod touch without useing itunes.
    as i see theres some people here that theires ipod touch are recongnzed as a digitl camra, mine is reconzied as nothing, some help plz.
    Message was edited by: B0Om

    B0Om wrote:
    ok but i still dont understed, only my itnes recongnize my ipod, when i go to " my cumputer, it dosent show up there, not even as a digital camra
    Your Touch is working correctly. Currently, without unsupported third party hacks, the Touch has NO disc mode. It will only show up in iTunes.
    how do i put programes and games in my ipod touch
    Right now, you don't. The SDK is scheduled to be released in Feburary. Then developers will be able to write programs that will be loadable.

  • Weird error message need help..

    SO.. i havent updated my itunes in a while because i keep getting this weird message.. it comes up when im almost done installing the newest/newer versions of itunes. it says
    "the feature you are trying to use is on a network resource that is unavailable" "click ok to try again or enter an alternate path to a folder containing the installation package 'iTunes.msi' in the box below"
    now when ever i choose a file from the browse box it replies with this message "the file 'xxx' is not a valid installation package for the product iTunes. try to find the installation package iTunes.msi in a folder from which you can install iTunes."
    no idea need help thanks
    ~~~lake
    Message was edited by: DarkxFlamexCaster
    Message was edited by: DarkxFlamexCaster

    +it comes up when im almost done installing the newest/newer versions of itunes. it says+ +"the feature you are trying to use is on a network resource that is unavailable" "click ok to try again or enter an alternate path to a folder containing the installation package 'iTunes.msi' in the box below"+
    With that one, let's try the following procedure.
    First, head into your Add/Remove programs and uninstall your QuickTime. If it goes, good. If it doesn't, we'll just attend to it when we attend to iTunes.
    Next, download and install the Windows Installer CleanUp utility:
    Description of the Windows Installer CleanUp Utility
    Now launch Windows Installer CleanUp ("Start > All Programs > Windows Install Clean Up"), find any iTunes and/or QuickTime entries in the list of programs in CleanUp, select those entries, and click “remove”.
    Next, we'll manually remove any leftover iTunes or QuickTime program files:
    (1) Open Local Disk (C:) in Computer or whichever disk programs are installed on.
    (2) Open the Program Files folder.
    (3) Right-click the iTunes folder and select Delete and choose Yes when asked to confirm the deletion.
    (4) Right-click the QuickTime folder and select Delete and choose Yes when asked to confirm the deletion. (Note: This folder may have already been deleted if QuickTime was successfully removed using Add/Remove Programs earlier.)
    (5) Delete the QuickTime and QuicktimeVR files located in the C:\Windows\system32\ folder. Click Continue if Windows needs confirmation or permission to continue. (Note: These files may have already been deleted if QuickTime was successfully removed using Add/Remove Programs earlier.)
    (6) Right-click on the Recycle Bin and on the shortcut menu, click Empty Recycle Bin.
    (7) Restart your computer.
    Now try another iTunes install. Does it go through properly now?

  • I got new hard driver for my MacBook I don't have the cd but I do have flash drive that has the software I need help because when I turn on my laptop it shows me a file with question mark how can I install the software from the flash driver?

    I got new hard driver for my MacBook I don't have the cd but I do have flash drive that has the software I need help because when I turn on my laptop it shows me a file with question mark how can I install the software from the flash driver?

    Hold down the Option key while you boot your Mac. Then, it should show you a selection of devices. Click your flash drive and it will boot from that.

  • Need help adobe bridge cc output module

    I need help. I have an assignment I'm held up on completing because the adobe cc bridge does not have the output modue I need. I followed the adobe instructions page to the letter. I copied and pasted the output module folder to the adobe bridge cc extensions folder in programs/commonfiles/adobe. The only thing is the instructions then say to paste the workspace file into the workspace folder located below the bridge extensions folder. I don't have a workspaces folder there or anywhere. I even tried must making one and adding the file to it, but no go. can someone PLEASE help me with this?    I have an assignment due like now that requires the use of the output modue.thanks!

    oh,my system is windows 8.1. sorry, lol.

Maybe you are looking for

  • Can I use the same nike+ sensor with two differet Ipods and register the trainings in onmly one account?

    Hello, I would like to know if I can use the same nike  Ipod sensor with two different ipods. I want to use the same sensor sometims with an Ipod touch and sometimes with an Ipod Nano, I want my trainings with both Ipods to be registered to the same

  • Mail not responding on 10.8.2 - SOLUTION!

    Has your Mail frozen since 10.8.2? Are you using multiple accounts?  If so then I may have the solution (perhaps single accounts have the same problem) My accounts were set up within mail preferences on 10.8.1.  When I upgraded to 10.8.2 Mail froze,

  • How to get the sorted Groups in Adminstration Portal

    after adding a Child Group to the parent Group the Child Groups are not sorted.So how to get the sorted list when any child group is added to a parent group.In which class we have to make the changes to get the sorted group.

  • Does the M58p Thinkcentre (3582) support GeForce GT640

    Afternoon, I recently aquired a M58p Thinkcentre (3582) and I really want to run 3 monitors off it. I have done some research and it would seem that the GeForce GT640 (DDR3) would do the trick (for my budget) but I was just wondering if the most rece

  • CRM transaction BP dumps

    Hi Experts, I've a problem in transaction BP. Iv'e CRM 7.0. When I open BP transaction and use BACK button (green arrow in the menu) a pop-up is displayed asking me if I confirm or not. If I select "NO" there is a dump. From St22 the error is "Unable