TIFF - Need to set Whiteiszero (JAI)

Hi,
I manipulate images, if it's a RGB picture, I change it to a gray scale and I change it again to a 1-bit pictures (bilevel). When I save this picture to a tiff, JAI set it's Photometric param to Blackiszero but I want to encode my picture with Whiteiszero....
My compagny use a old tiff viewer, so when I open my encoded file, all pixels are inverted, I really need to set "white is zero" to fix that problem...
I use this code to convert to a 1-bit
PlanarImage dst =
JAI.create("binarize", src, new Double(200));
And I encode my TIFF with this code:
int TIFF_PHOTOMETRIC = 262;
TIFFEncodeParam params = new TIFFEncodeParam();
params.setCompression(TIFFEncodeParam.COMPRESSION_GROUP4);
TIFFField[] extras = new TIFFField[4];
extras[0] = new TIFFField(TIFF_PHOTOMETRIC, TIFFField.TIFF_SHORT, 1, (Object) new char[] {0});
extras[1] = new TIFFField(TIFF_XRESOLUTION, TIFFField.TIFF_RATIONAL, 1, (Object)new long[][] {{(long)200, (long)1},{(long)0 ,(long)0}});
extras[2] = new TIFFField(TIFF_YRESOLUTION, TIFFField.TIFF_RATIONAL, 1, (Object)new long[][] {{(long)200, (long)1},{(long)0 ,(long)0}});
extras[3] = new TIFFField(TIFF_RESOLUTION_UNIT, TIFFField.TIFF_SHORT, 1, (Object) new char[] {2});
params.setExtraFields(extras);
ImageEncoder encoder = ImageCodec.createImageEncoder("TIFF", out, params);
encoder.encode(image);

I found the solutions to force JAI to encode with the tag PhotometricInterpretation set to white is zero.
Thanks to Klaus Bartz.
You need a binarized image.
// Invert the colormodel
byte[] map = new byte[] {(byte)( 255),(byte)(0)};
IndexColorModel colorModel = new IndexColorModel(1, 2, map, map, map);
// Create a bufferedimage with the good colormodel
BufferedImage bi = new BufferedImage(newImg.getWidth(), newImg.getHeight(), BufferedImage.TYPE_BYTE_BINARY, colorModel);
bi.setData(newImg.getAsBufferedImage().getData());
// Invert the image
DataBufferByte dataBufferByte = (DataBufferByte)bi.getRaster().getDataBuffer();
byte[] buffer = dataBufferByte.getData();
for (int lll = 0; lll < buffer.length; lll++) {
buffer[lll] = (byte)(~buffer[lll]);
PlanarImage = PlanarImage.wrapRenderedImage(bi);

Similar Messages

  • Help needed in setting up Japanese Database

    Hi there,
    Help needed in setting up Japanese Database.
    I created database with UTF8 character set on Sun Solaris O/S.
    Oracle version 8.1.7.
    I am accessing the DB through SQL*Plus (Windows client).
    I downloaded the Japanese font on client side and also set the NLS_LANG environment variable to Japanese_Japan.UTF8. Still, I am not able to view Japanese characters. O/S on client side is Windows 2000 professional (English). Is O/S (client) need to be Japanese O/S? When I try to retrieve sysdate, its displaying in Japanese but not all characters in Japanese. Can anyone help me out how to set up the client and is there any parameters to be setup at server side? I also tried to insert japanese characters into table through client, but it displaying as "?????" characters. Any help in this regard is appreciated.
    Thanks in advance,
    -Shankar

    lol
    your program is working just fine.
    do you know what accept does? if not read below.
    serversocket.accept() is where java stops and waits for a (client)socket to connect to it.
    only after a socket has connected wil the program continue.
    try putting the accept() in its own little thread and let it wait there while your program continues in another thread

  • Have problem setting Email alerts for Calendar events. Warning message says I need to set up a card in Contacts with my email. I do but it doesn't recognize it. How do I indicate the email I want alerts sent to?

    The system of setting up email alerts for Calendar events worked fine in Snow Leopard but since I upgraded to Mt. Lion Calendar won't let me set email alerts. When I try, I get an error message saying I need to set up a card in Contacts for my email. I have a card set up in Contacts for both of my email addresses but it doesn't recognize them. Perhaps the name I have on the card doesn't match a name that Calendar is looking for. Calendar doesn't seem to have a way in Preferences or elsewhere to indicate the email I want alerts sent to. Any ideas how I can get this system working again? Thanks for your help.

    You might want to consider starting a new discussion. Since this one is marked solved, less people are likely to look at it. You can link to this one.
    See if another contact is marked as this is my card.

  • My Apple TV all of a sudden refuses to show my movies from my MacBook and says it needs to set time network. What is that?

    My Apple TV all of a sudden refuses to show the movies from my MacBook and says it needs to set time network. What is that?

    Welcome to the Apple Community.
    The Apple TV should set it's time automatically from the network time server, if it isn't doing this try restarting the Apple TV by removing ALL the cables for a 30 seconds, if this fails try resetting or restoring it.

  • Need to set/read 'Keyword' in a PDF programatically

    We have adobe professional license ver 9.
    When a user downloads a PDF from our custom web application (C#), we need to set a keyword (attribute) to the PDF automatically. The 'Keywords' field in 'File > Properties' seems to be ideal location.
    User typically edits this downloaded PDF and uploads it again back to the web application. During this editing, the keyword is assumed to remain the same.
    Finally, user uploads the edited PDF back to the web application. At this point, the keyword is to be read from PDF.
    Kindly suggest API's to set/read keyword.

    This is not a scripting question. The solution needs to be in the custom
    application you're using to create the PDF files.
    The "Keywords" field is just a part of the document metadata, which any PDF
    library should be able to edit.
    On Fri, Dec 9, 2011 at 12:54 PM, sandhya_sky is the limit

  • HT204053 I share an iTunes account with my daughter, I just got an ipad and need to set up with my own I'd for iCloud sync  how can I keep my apps and music?

    I share an iTunes account with my daughter, I just got an ipad and need to set up with my own I'd for iCloud sync  how can I keep my apps and music?

    ColleenMcG wrote:
    You can continue to share the same iTunes account ID with your daughter and set up a separate iCloud account with a different ID.
    => is this a different iCloud account for each device?  I thought iCloud account ID had to match some iTunes account ID, for which we only have one i Tunes account?
    You need to set up a separate iCloud account for each person that does not want to share their iCloud data.  If you share an iCloud account with someone, any data you both sync with the shared account is merged, and you end up with each other's data on your device(s).  If, for example, you owned two devices and someone else in the family also owned two devices, you would both want your own iCloud accounts, and you would each set up your personal iCloud account on the two devices you own.  In other words, you want a separate iCloud account for each person to be used on the devices they own.  Each iCloud account has to have a separate Apple ID.  The ID does not need to be the same as the ID used for iTunes.  Many families perfer to share the same iTunes account/ID, but maintain separate iCloud accounts with different IDs to keep there data separated.
    ColleenMcG wrote:
    It does not need to be the same as the ID used for iCloud.
    => what ID, iTunes?  So I can have a separate iCloud account "only" ID which I also assume must be some [valid] email address?  The children currently do not have email accounts anywhere.
    Yes, I was referring to the iTunes ID not needing to be the same as the ID used for iCloud.  In order to set up an Apple ID your children will need to have a valid email address that can be verified by Apple.  Apple requires this so they have a way of contacting the owner if there is a problem with the account, such as when you may need to reset the password on the account.  When you set up the ID, Apple will send a verification email to this email account and you will need to click on the verificating link in the email to complete the process.  If they don't currently have an email account you can just set one up with gmail or another free email hosting service.  They don't have to use the account but you will need it to set up the ID.

  • I try to insert some images on a website but the images are not in the right color mode. I do not know what to do? and also I have 1200 images to insert so I can not change one after one. So I need to set up an action, but I donot know how to do it... Tha

    I try to insert some images on a website but the images are not in the right color mode. I do not know what to do? and also I have 1200 images to insert so I can not change one after one. So I need to set up an action, but I donot know how to do it... Thanks

    What is the problem specifiaclly?
    If the images are intended for web use I would recommend converting them to sRGB which could be done with Edit > Convert to Profile or with File > Save for Web, but as including a Save step in Actions and applying them as Batch can sometimes cause problems I would go with regular converting.
    You could also try Image Processor Pro.
    Scripts Page

  • We just purchased a new computer and need to set up Itunes on it for the 3 members of our family.  What is the best way to go about that?

    We have just purchased a new home computer and need to set up I-Tunes for everyone in our family.  Is that possible to do on one computer?

    To have  EVERYTHING  as it is Now...
    From your OLD computer...
    Copy your ENTIRE iTunes FOLDER to an External Drive... and then from the External Drive to your New Computer..
    Full Details Here  >  http://support.apple.com/kb/HT1751
    An Added Bonus is that you will have a Backup of iTunes.

  • HOW TO?: Need help setting up 3 different iCloud accounts for my kids (so each has own iMessanger)using same Apple ID (mine) ....they don't have their own separate email addresses to work from...how do I do this?

    Need help setting up 3 different iCloud accounts for my kids (so each has own iMessanger)using same Apple ID (mine) ....they don't have their own separate email addresses to work from...how do I do this?

    Any devices connected to the same icloud account can sync all the data on that account.  For this reason an icloud account is really for a single user.
    On a mac, if each user has their own account, then the itunes for that mac account should be set up to connect to that user's icloud account (System preferences>icloud).

  • In the new mail app for OSX v10.7 Lion it seems I can only setup my gmail account as an "imap", when I need to set it up as "pop"... PLZ HELP I NEED MY MAIL TO WORK!!!

    In the new mail app for OSX v10.7 Lion it seems I can only setup my gmail account as an "imap", when I need to set it up as "pop"... PLZ HELP I NEED MY MAIL TO WORK!!!

    Go to System prefs
    Select Mail Contacts and Calendars
    Then select Other
    Then select "Add a Mail Account and click create
    Then go to google for the settings you need:
    First here for the settings online at gmail http://tinyurl.com/du3fu
    Then here for the setting in mail http://tinyurl.com/38fevm8
    These are instructions for Mail 4.0 but all of the necessary settings should be listed.

  • I have just brought 2 mini's for my boys for xmas.  1. can I connect them both to my existing Itunes account or do I need to set up something different. and 2. can they be used on their dads account as well as mine, or only one?

    I have just brought 2 mini's for my boys for xmas.  1. can I connect them both to my existing Itunes account or do I need to set up something different. and 2. can they be used on their dads account as well as mine, or only one?

    You can set them up with your Apple ID if you want to. You can also set them up with their dad's Apple ID. Depending on how old the boys are, you can even let then have their own Apple ID's. The one thing that you don't want to do is have them use more than one Apple ID on their iPads.
    If you want to be able to share purchased content, then setting them up with either your ID or your husband's (?) ID would be the way to go. If the boys share an ID with one of you, they can download content that you have already purchased without having to pay for it again.
    If you and have the financial wherewithal to allow them to purchase their own individual content, I would recommend letting them have their own Apple ID. This way, as they grow older and eventually move on, they will have their own accounts, their own purchases .... No ties needed to your ID or to dad's ID. FaceTime and Messages will be a little easier to set up if they have their own ID's and they can have their own iCloud accounts as well. However, they must be 13 years old in order to have an Apple ID and iTunes account. If they are under 13, then it's a no brainer you will have to use yours or their father's ID.
    Whatever you decide to do, just don't switch from one ID to another ID on the iPads. That gets confusing and they could end up locking themselves out of one of the ID's for 90 days if they download a past purchase using a different ID.

  • I need to set up an apple ID for my IPAD but my daughter was already using my email address for her itunes

    I need to set up an apple id for my IPad but my daughter is using my email address to purchase music for her IPOD and IPhone.  How can she delete her apple ID so that I can use my own email account?

    Try getting a credit card from the same people who issued the debit card. If I read the home sharing paper properly after your set it up with the credit card you can change the payment method back to debit.

  • Hi. My husband and I have always shared the same iTunes account.  Since installing iCloud, all our contacts and calenders have merged on our iPhone 4, which we do not want.  How do I rectify this? Does my husband need to set up his own apple ID?

    Hi. My husband and I have always shared the same iTunes account.  Since installing iCloud, all our contacts and calenders have merged on our iPhone 4, which we do not want.  How do I rectify this? Does my husband need to set up his own apple ID?  If so, where do I need to change his email address info, so that his calender and contacts remain his?  Thank you

    You can continue to use the current AppleID for iTunes, but your husband can create a new AppleID to use to create a new iCloud account that will be his own and not overlap with yours.  If you do not have another email address to use for an AppleID, just get a free Gmail account and use that.
    You can have as many AppleIDs as you want (or at least, as many as you have email addresses for).  You can use a separate AppleID for the store, another for iCloud, and even another for iMessage if you wish.
    You will want to keep the current one as the shared one for the store as all your previous purchases are permanently tied to it, and thus you need that AppleID to update or redownload your current purchased content.

  • HT5622 I have just received a new iphone 5s and need to set the Apple ID with my work email.  I used my work email on my personal iphone 4s to set up an icloud account and it will not let me use my work email as the Apple ID on my new iphone. What do I do

    I have just received a new iphone 5s and need to set the Apple ID with my work email.  I used my work email on my personal iphone 4s to set up an icloud account and it will not let me use this email as the Apple ID on my new iphone.  As it is a work phone I need to use this email address as my Apple ID.  How do I do this?

    when you open the app store scroll down to the bottom it will display the apple id currently in use, change it to your normal apple id email

  • Can I sync my iPhone and my wife's iPhone calenders through the same iCloud account? Or do I need to set up 2 different apple id's anc iCloud's

    Can I sync my iPhone and my wife's iPhone calenders through the same iCloud account? Or do I need to set up 2 different apple id's and iCloud's

    No, I would recommed to use two separate iCloud accounts for mail, calendars, notes, reminders, contacts etc.

Maybe you are looking for

  • How can access MS Outlook Calender information  from my Java application.

    People schedule meeting with some data on regular basis. I need to access the Exchange server from my Java application and get the meeting dates along with other data pertaining to meeting.

  • Delivery created with out stock

    Hi folks,              Sales order has been created for 'X' material,but there is 0 stock available for this material "X", ATP has been carried out and has proposed a further date, but when try to create a delivery,delivery documnet has been created

  • ERROR  IN IMPORTING RECORDS THROUGH DTW

    Hi Experts, I am trying to import more than 25000 items using DTW and i am getting the error msg, is displayed tht created failed and it is displaying only "20" items which r not imported but actually none of item is not imported. why it is not displ

  • Power Down while creating array...

    Hello all, I just found out that I need to do a unexpected shut down of an Xraid tonight. No biggie except for the fact that one side is 45% done burining in a new array. If I power down the Xraid while the array is being created would it somehow har

  • Should I install Crystal Reports Enterprise SP01 or SP03?

    Hi All We are using BO 4.1 SP02 and are now getting round to installing Crystal Reports Enterprise. I have two questions I can't find answers for: 1. Should I be installing SP01 or SP03 of CRE. Our BO platform is SP02, but there is no CRE SP02, so I