GreyScale to Black and White

Hey,
I'm having a few problems converting a grey scale BufferedImage to black and white. I create the BufferedImage as greyscale:
Image image = Toolkit.getDefaultToolkit().createImage(source);
// Create a grayscale color model.
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
int bits[] = new int[]{4};
ColorModel cm = new ComponentColorModel(cs, bits, false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
WritableRaster raster = cm.createCompatibleWritableRaster(image.getWidth(null), image.getHeight(null));
// use the colour model to create the buffered image
BufferedImage bimg = new BufferedImage(cm, raster, false, null);
bimg.createGraphics().drawImage(image, 0, 0, null);I then do some processing on the image, but when i go to save it, i want it to be black and white to reduce the file size and allow for G3 TIFF compression. I was able to convert it to black and white, but the file size of the TIFF didn't really reduce to much. When I was saving the image as grey scale they averaged at about 600Kb, now with black and white they average at 500Kb, but they should be much lower. Here is how i convert them to BW:
byte[] darkLight = {(byte) 0xff, (byte) 0};
IndexColorModel blackAndWhite = new IndexColorModel(1, 2, darkLight, darkLight, darkLight);
BufferedImage bwImage = new BufferedImage(image.getImage().getWidth(null), image.getImage().getHeight(null), BufferedImage.TYPE_BYTE_BINARY, blackAndWhite);
bwImage.createGraphics().drawImage(image.getImage(), 0, 0, null);
image.setImage(bwImage);I was wondering if there is a more efficient way of doing this, i.e meaning a way to convert the image without creating a new one in memory. and also any information on why the image is still taking up so much space even though it if BW.

That code will work, but is there a way to do this conversion without creating a new bufferedImage, memory could be an issue, since i'm working with really large bufferedImages

Similar Messages

  • HT4356 How can I print a greyscale/fast document from my iPad wireless printer. It will print in color and high quality but want black and white

    How can I print a greyscale/black and white document from my iPad wireless printer???
    IT will print in COLOR and high quality print but would like to conserve ink (Esp. Coloured )
    is there a way to reconfigure settings either on my iPad or the printer ??? Cannot find a setting
    when u select print on the ipad it dos not allow you to change your settings before you print

    There is no setting for this. You can request it here:
    http://www.apple.com/feedback/

  • Identifying black and white versus greyscale in PDF

    Is there a way to identify from within a scanned PDF document (ie, something like a document property) that it was scanned as greyscale, black and white, or color?  My company is using Acrobat 7.0.  We have a requirement, for a variety of reasons, that PDFs for certain projects be provided as black and white scans only, but all too frequently we get them in greyscale or color.  We need to be able to easily identify that a PDF is not black and white.
    Thanks in advance!

    Try the Preflight Tool.

  • Officejet 6000 using color ink when set to greyscale black and white only

    I have two new Officejet 6000's and both run out of color ink even though I have them set to print greyscale black and white only.  I almost never use color.  The drivers are the latest versions.   Connected via ethernet cord.  Vista Home Premium 64 bit.  Color ink is too expensive to waste it like this.  Does anyone have a reason and/or a solution why the color ink is running out when I have it set to black and white only?
    Apparently it is an issue with some others too.  See this thread on the 6500: http://h30434.www3.hp.com/t5/Mac-printing-and-scanning/HP-OfficeJet-6500-will-not-print-using-black-...

    I know these posts are old, but.
    To force the print to print even though some carts are empty or expired. Turn the printer off. Then hold the feed button while turning the printer on. Keep the feed button pressed for about 4-5 seconds after powering on the printer.

  • How to record video in black and white mode

    Hi,
    I am developing a live video recording application and my application  have black and white mode recording feature, So please give me some idea  about black and white recording.
    Thanks
    Ram

    Your 1200 is fine it will print in B&W using these settings:
    in the print driver drop down box, select Color Options and tick the print in Greyscale option
    then click in the Presets dropdown and select save as  and type in a description  such as " Black and White"

  • Animated gif changes to black and white when exporting

    A student created an animated gif of a solar system for class. When he tries to export it as an animated web gif, it changes everything to grayscale.

    If you go to File>Image Preview, there's a drop down menu called "palette". This is probably set to black and white or greyscale. Change it to exact or adaptive.

  • How do I print black and white on Mountain Lion?

    Hey.
    Does anyone know how to print black and white on Mountain Lion?
    I searched the community and Google but I couldn't find anything...
    Regards,
    TeaDragon

    It's usually in the Print dialog when you File > Print.  Select the Show details button, the change the option in the horizontal line to Paper Type/Quality.  Click the Color Options triangle and change Color to Greyscale.

  • How can I print in black and white?

    I have asked friends how to print in black and white and they show me how to do it on their computers. They do it by just switching the colorysync profile to black and white or greyscale but when I go to print and go to the same drop down menu for colorsync profiles, there are no other profiles.

    First, as print dialog box functions vary with the Mac OS version, we need to know what version of the Mac OS you have. "iOS 5.0.1" in your profile is not a computer OS but rather for iDevices. Do "About this Mac" from the Apple menu to see what version you really have. It should be 10.something
    Second: control of the type of printing is int eh hands of the printer software, Please post the both the make and model of printer you are using.

  • How to print in black and white only?

    Hello,
    I have HP Color Laserjet cp1515n. I downloaded and installed "HP_CP1510_series_full_solution_EMEA3-v4.0" from HP's website for the driver. 
    When printing (in the properties for the printer) there is no option whether to print in black and white only or not. Please help me get that option. And please tell me how I can save toner.
    Thank You
    I have windows xp 

    Hello!
    You can get this accomplished within most word/printing applications or preferences by selecting 'Greyscale' printing or black and white only.
    You can find an article related to this function with more details here:
    http://h10025.www1.hp.com/ewfrf/wc/document?docname=c01514143&tmp_task=useCategory&cc=us&dlc=en&lang...
    Hope this helps!
    Help the community by marking this post as a solution if it solved your issue!.
    If my post helped you in any way, please click the blue KUDOS star under my name! It would mean a great deal.

  • Print black and white only, on Hp photosmart 5514.

    Hi,
    I dont like it at all that i have to contact support forums for something like this.
    it use to be so easy to choose color or black and white printing.
    Why have you made it so difficult ? Totally pisses me off but i leave that for the feedback section.
    I have seen others with the same problem so it is not only me. now it has taken more than 20 minutes and i have to get to work soon.
    So, how do I print black and white (or greyscale) using my newly bought hp photosmart 5514 ? ( is it smart ???)
    I have been wasting a lot of ink now, very unsmooth not having it available in the ordinary printing window.
    Like it matters, i use win 7 blablabla

    I also hate that there is NO WHERE to find a simple answer.  I have a "HUGE" XL cartridge of black only.  Then I have to buy all the stupid little tiny color cartridges AND another little black cartridge.
    Here I suppose: when I print in color, I use the color + small black cartridge.
    When I want to print BLACK ONLY or GRAYSCALE, I choose that and it only prints using the XL big black cartridge.
    WRONG.  And no one can seem to answer this correctly, t but I know it does not work.
    Remove 1 empty color cartridge whole printer won't work, even if I want black print only.
    If all the small "color" cartridges + small blk cartridge is low but the BIG BLACK cartridge is showing full, still won't print BLACK ONLY.
    I cannot PRINT with this stupid printer unless all cartridges have ink and are inserted.  STUPID
    I am now late to work simply because I cannot print a document PERIOD unless I have full color sitting there.
    I just tried it multiple ways, grayscale, black only blah blah and it ALWAYS came out too- light, ie the sm blk cartridge was being used and it is admittedly LOW ON INK.  WHAT is the big black cartridge doing there, saying it is full and not printing "black only" or "grayscale"? 
    The only article I could find that halfway enlioghtened me to the problem was HP page stating that "black"  is never really black, to improve quality (thanks for making the decision for me) HP adds just a bit of color here and there to make black really black for paper quality paper.
    SO SNARLING.  Going to *bay to get refilled cartridges so I can print in a week.  SNARL

  • How do i get Firefox to print web pages in black and white only (colors are interpreted in grayscale and some are too light to be read)?

    i have a black and white laser printer. Firefox prints web pages by sending color images to my printer. The printer uses greyscale to interpret the colors. i really want Firefox to send black and white images to my printer, because with greyscale some of the colors are translated to print that is too light to be seen clearly.
    Can this be done?
    Thanks,
    Chazbo

    i just tried disabling adblock and checking if i had any no script or noscript sort of addon. i do not have a script killer. disabling adblock did not solve the issue.

  • How do I set my printer to only print in black and white?

    Hi, 
    I was wondering if anyone can help me. I want to be able to print in just black and white on my printer. 
    My printer is a HP Officejet Pro 6830, and my computer operating system is Mac OS X 10.10 Yosemite. 
    I do not have an option on my word program that allows me to 'greyscale' or any type of colour option. 
    Any help would be great, thank you in advance!
    This question was solved.
    View Solution.

    Hi,
    Follow the steps below to print using Black Ink only:
    1. From the application used to print, click the File menu and select Print. The Print window appears.
    NOTE: The Print window might be minimized: Click the Show Details button to see all available settings.
    2. To access the color options, click the lowest selection box listed as the name of the program (e.g. TextEdit)
    Will appear as Copies & Pages within Microsoft Office applications.
    3. Select Paper Type/Quality from the drop-down menu.
    4. Click the triangle next to Color Options to expend the settings.
    5. Set the Color field as Grayscale.
    6. Set the Grayscale Mode as Black Ink Cartridge Only.
    You may save the settings for future use by clicking Presets > Save Current Settings as Preset...
    Any used preset will remain default so simply select teh standard preset to print in color.
    Shlomi
    Say thanks by clicking the Kudos thumb up in the post.
    If my post resolve your problem please mark it as an Accepted Solution

  • How do I print in black and white with HP Deskjet 5740?

    I have just updated from Snow Leopard to Mountain Lion. With Snow Leopard, and an HP Deskjet 5740 printer, I could choose to print in draft or best quality, black and white only or in full colour, and had various other options. Now I am not offered these options in the print dialogue: the printer always prints in colour and I cannot choose whether to print in best or draft quality. I would be grateful for any tips on how to recover printing options. Many thanks.

    I have a different HP, but see if this helps:
    You can also select Greyscale, and even only the Black Cartridge:
    (you can save it as a Preset)

  • Problem in scanning black and white documents using acrobat 9.0 pro.

    when i select file from the menu bar -create pdf-scanner-black and white docment,  the logos and images from that page appear as black boxes. I have tried it with different scanners of same model and with different pages and on different machines. I have windows xp pro. Can someone please tell what to do to overcome this problem.Its really urgent....Thank you in advance..

    The problem lies with the settings in your scanner's settings. I'd suggest trying to scan as greyscale rather than B&W.

  • IPhone 4S only displays in Black and White. How do you restore color?

    I have an iPhone 4S. The screen only displays in black and white. How can I restore the color to the display screen?

    Triple click the home button to switch of the greyscale feature.
    Turn Greyscale on or off. Go to Settings > General > Accessibility > Gtreyscale. Or, use the Accessibility Shortcut. See Accessibility Shortcut on page 139.
    Accessibility Shortcut
    Use the Accessibility Shortcut. Press the Home button quickly three times to turn any of these features on or off:
    VoiceOver
    Invert Colors
    Grayscale
    Zoom
    Switch Control
    copied from page 150 of the user guide iOS8

Maybe you are looking for

  • Is there a way to set a limit on the number of characters each cell will hold in numbers?

    Hi there, I'm creating a CSV file via Numbers and would like to set a limit to the number of characters a cell will hold in numbers. This way, when I copy text from my source, and paste it into the numbers cell, the text will be cut off at the charac

  • Windows 7 Home Sharing Problem (wireless/ Ethernet)

    Hello I spent a few days trying to figure out why home sharing didn't work. I've got 2 windows 7 pc. So comptuer A can detect computer B iTunes library but computer B cannot detect computer A library although the settings such as allow sharing on iTu

  • Swapping between windows in Word for Mac 2011?

    I've just installed Word for Mac 2011 on my new Mac Mini, and somehow the Command+` keyboard shortcut for switching between open Word windows is not working anymore. I've tried to find the answer online, but everyone states to use Command+`, which is

  • Camera Raw Version 5.7 and Nikon D800E

    Hi everyone,  So with my new Nikon camera (D800E), I now realize that I can do nothing in CS4 with my RAW files. As my current version of Camera Raw is only 5.7 for it. Will I have to upgrade my version to at least CS5 with ACR 6.7 minimum? Maybe go

  • Help!! my g4 is dying.......

    the most bizarre thing happened this morning. got home from apple store last night with a brand new end of line xeon octocore mac pro. went to bed. got up this morning and started using my aging g4 867mhz single processor on the internet and it sudde