Need conversion mechanism for converting 24 bit image to 16 bit

In my java project I need to convert 24 bit image to 16 bit image. I don't have any clue. Please provide me the option to implement it.
Thanks,
jai

That doesn't tell me much, and I know what you're talking about. I doubt that it tells the OP anything useful whatsoever.Sorry EJP, it was a mouthful I know. Maybe this will help instead, a ColorConversionOps class to work on *32 bit > 16 bit > 32 bit colors*. To help clarify where the 16 bit color input and output goes, some of the methods return or require parameters of type short. Also take notice the bitmask for variables of type short vs the bitmasks for int. AND pay particular attention to the unsigned right bit-shifting of the most-significant-digit.
public class ColorConversionOps
  public static short convert32_16(int rgb) {
    int a = ((rgb & 0xF0000000) >>> 16);
    int r = ((rgb & 0x00F00000) >>  12);
    int g = ((rgb & 0x0000F000) >>   8);
    int b = ((rgb & 0x000000F0) >>   4);
    return (short)( a | r | g | b);
  public static int convert16_32(short rgb) {
    int a = ((rgb & 0xF000) << 16);
    int r = ((rgb & 0x0F00) << 12);
    int g = ((rgb & 0x00F0) <<  8);
    int b = ((rgb & 0x000F) <<  4);
    return (a | r | g | b);
  public static void printRGB_32(int rgb) {
    System.out.println("a="+((rgb & 0xFF000000) >>> 24));
    System.out.println("r="+((rgb & 0x00FF0000) >>  16));
    System.out.println("g="+((rgb & 0x0000FF00) >>  8));
    System.out.println("b="+ (rgb & 0x000000FF));
    System.out.println();
  public static void printRGB_16(short rgb) {
    System.out.println("a="+((rgb & 0xF000) >>> 12));
    System.out.println("r="+((rgb & 0x0F00) >>  8));
    System.out.println("g="+((rgb & 0x00F0) >>  4));
    System.out.println("b="+ (rgb & 0x000F));
    System.out.println();
}Now to make the conversion from 32 bit color to 16 bit color and back. NOTICE there willl be a loss of precision -- just like someone else has already said.
public class Test
  public static void main(String[] args)
    int rgb = 0xFFFFFFFF;
    ColorConversionOps.printRGB_32(rgb);
    //a=255
    //r=255
    //g=255
    //b=255
    rgb = ColorConversionOps.convert32_16(rgb);
    ColorConversionOps.printRGB_16((short)rgb);
    //a=15
    //r=15
    //g=15
    //b=15
    rgb = ColorConversionOps.convert16_32((short)rgb);
    ColorConversionOps.printRGB_32(rgb);
    //a=240
    //r=240
    //g=240
    //b=240
}And now we see, the reason 16bit color is so unpopular to the rest of the world, but not for us here!

Similar Messages

  • Can PSE8 for mac convert an 8 bit image to 16 bit?

    can Photoshop Elements 8 for mac convert an 8 bit image to 16 bit?
    I use Photomatix Pro and when I am working with a single image in Photomatix Pro, it has to be 16 bit.

    Yes, you can. These are the steps when using the elements editor.
    Depending on the file format:
    1. If this file is from a camera raw file, simply open the original
        raw file and at the bottom of the camera raw dialog choose 16 bits.
        This would open the file in pse editor as a 16 bit file.
        Then save as a tif file with no compression.
    2. If the file is a jpg or tif file, in the pse editor select: File>Open As>Camera Raw.
        This will open the file in the camera raw dialog. Then select 16 bit from the menu
        at the bottom of the camera raw dialog. After the file opens in pse editor, in 16 bits,
        save as a tif with no compression.
    3. If the file is a psd file with no layers, then step 2 will work. If the psd file has layers,
        open the the file in pse editor and resave the file using maximize compatibilty.
        This will allow the psd file to have both layers and open in the camera raw dialog as
        in step 2. When you open the file in the pse editor, it will just be a single layer and then
        just save as a tif file with no compression.
    Hope this helps.
    MTSTUNER

  • Need Function Module for convertion of  Foreign currency to Indian currency

    hi friends,
    i need function module for converting amount from
    Foreign currency to Indian currency
    thanks

    hi Venkat,
    Please use the function module CONVERT_TO_LOCAL_CURRENCY
    <b><u>Sample code:</u></b>
          call function 'CONVERT_TO_LOCAL_CURRENCY'
            exporting
              date             = p_alv_tab-begda
              foreign_amount   = p_alv_tab-kkost_p_person
              foreign_currency = p_alv_tab-kwaer                 " foreign currency
              local_currency   = l_ev_waer                           " Indian currency
            importing
              local_amount     = p_alv_tab-kkost_p_person
            exceptions
              no_rate_found    = 1
              overflow         = 2
              no_factors_found = 3
              no_spread_found  = 4
              others           = 5.
    Hope this helps,
    Sajan Joseph.

  • How to convert a 16-bit image to 8-bit

    I am having difficulties in skeletonizing my image. Although I already threshold my image, it still cannot be skeletonized. When I create the image using IMAQ create, the image type must be set to 16-bit, otherwise it will create an error message. An enthusiast in the forum told me that the image must be 8-bit so that it can be skeletonized. But I do not know how to convert the image from 16-bit to 8-bit. So is there anybody out there that can provide me with a solution. Attached is the VI that I used. Really appreciate your help.
    Attachments:
    Image_Acquisition.vi ‏68 KB

    Try using the IMAQ Cast Image function under Motion & Vision>>Vision Utilities>>Image Management>>IMAQ Cast Image.
    Regards,
    Steve

  • Please help us, after we installing the flash player is said that the plug-in version is not installed and i need Flash Player for my windows 7 Professional 64-bit Japanese version and Internet explorer 10

    Please help us, after we installing the flash player is said that the plug-in version is not installed and i need Flash Player for my windows 7 Professional 64-bit Japanese version and Internet explorer 10

    Hello,
    There are two versions of Flash Player for Windows:  ActiveX for Internet Explorer and Plug-in for non-IE browsers. It appear you may have installed the one for non-IE browsers.  Please use the links below to download and install:
    Flash Player ActiveX (Internet Explorer
    Flash Player Plug-in (All other browsers)
    Maria

  • Quicktime converting 24 bit images to 16 bit images on paste

    I am doing image processing of a QuickTime (7.1.5 pro) movie in Photoshop (CS2) using Applescript. When I copy an image (either with Applescript or manually) and paste it into a new QuickTime Player movie the image gets converted to a video depth of 16 (thousands) rather than 24. I have tried:
    set DestMovie to make new movie with properties {data rate:SourceRate, video depth:24, high quality:true} -- I also tried video depth:0
    paste
    I also try:
    tell movie 1
    paste given video depth:24 -- I've also tried just paste
    end tell
    and still it converts my images to thousands. The image gets to photoshop perfectly. If I paste it into a Pages document the image depth is correct. I have tried both RGB and CMYK in 8 and 16 bit depths in Photoshop. If I save the file as JPEG in high quality mode and then open the file with Quicktime and copy and paste it, it works great, the only problem is I then have to make a new file for every image I process because if I close the file, QuickTime keeps it open so Photoshop can't then save to the same file.....
    Will someone please help me figure out how to keep my image quality on pasting into Quicktime???
    Thanks
    Powerbook G4   Mac OS X (10.4.9)  

    I open my original movie in Quicktime. I make a new movie in Quicktime for the modified images to be pasted into.
    I copy the current frame from my source movie and paste it into Photoshop. I do my image processing and then save as a jpeg high quality and close my file (which strips out the audio from a muxed mpeg-1 file) then reopen the file in Photoshop. Now I have a good quality image in Photoshop. I have been using RGB 8 bit as my mode in Photoshop. I only tried CMYK to see if it would work better. It was exactly the same.
    I then do a select all and copy in Photoshop, then go to Quicktime and do a paste. This is when it gets converted to 16 bit depth. If I do the same exact sequence and paste into a Pages document the image stays 24 bit, so I am pretty sure it is something in Quicktime.
    Again, if I save the file in Photoshop and then open the same file in Quicktime, copy the image and then paste it into my destination movie, it works great. The only problem with this method is I have 15 minutes of video to process with is 27,000 jpeg files in the end. I prefer to use one file if I can. The reason for the 27,000 files is that when I open an image in Quicktime and paste it into a movie, it saves it as a track in the movie and even when I close the original file, Quicktime keeps it as in use. When I look at the movie properties, it keeps the original file in the list until I do a save as movie and it flattens the movie. If I flatten the movie once, then when I do another save, it keeps the original file open again. I would have to do a save as movie... again 27,000 movie files now. Geez...
    Thanks!

  • Need a mechanism for turning ON/OFF SOPs

    hi all,
    please help me in finding a solution::: the scenario is I have some 20
    classes and each has 2 methods and those methods has
    System.out.println(" some text "). i need a mechanism to turn ON/ OFF
    the SOPs to be printed in the console.
    I have two possible ways
    1. using javaw instead of java which will bypass the console.
    2. using an if condition
    for eg:[
    class A
    boolean a = false;
    if(false)
    System.out.println("some text");
    }but I need to have this IF condition check at each n every method is
    there any possibility that I can have only one check that can turn
    ON /OFF the SOPs
    or please help me with other alternatives.
    thanks in advance

    Or just use a small class rather than create your own PrintStream:public class Outputter {
        private static boolean enabled;
        public static void setEnabled(boolean b) {
            enabled = b;
        public static void println(String s) {
            if(enabled) System.out.println(s);
    }

  • Convert 256-bit image to one-bit

    I want to convert 256-bit bmp image to 1-bit.So please help me.

    armalcolm wrote:
    OK here's a frameworkUmm... Drawing onto a BI of TYPE_BYTE_BINARY should achieve this in just a few lines. The API says
    When color data is stored in an image of this type, the closest color in the colormap is determined by the IndexColorModel and the resulting index is stored. Approximation and loss of alpha or color components can result, depending on the colors in the IndexColorModel colormap.
    Of course, if this is homework then OP will probably be required to reinvent the wheel.
    db

  • Save 12 bit image as 12 bit image, not 16 bit

    Hi all,
    I have 12 bit gray scale images coming from a camera and am trying to save these images.
    I called function "IMAQ Write to File 2" to do this job.
    The function always scales the original data from 12 bit to 16 bit and then save it. 
    In the end, I have a 16-bit tiff image.
    Is there anyway that I can save my original 12 bit data without any scaling?
    Thanks a lot for your information.

    hi,
    for every data you save, a specific data type is used...so for example 16 bit integers, 8bit integers... there's no datatype with a length of 12 bit, so this can't be done by "simple methods"...if your intention is to save hard disk space, then better use a compression or use tif-files with lzw-compression. if you really like to save 12 bit, you can do it like this: use for example 16 bit integers for saving, but only use 12 bit...the left four bits are used by the next integer and so on:
    2 16 bit integers:
    1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1  -  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 - ...
    use them as follow:
         FIRST 12 BIT        SECOND 12 BIT         AGAIN 12 BIT
    1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2     2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
    This will be a lot of calculation stuff, you can for example do it by converting a number to a bool array or mathematical functions...as you like
    Hope this helps
    christian
    THINK G!! ;-)
    Using LabView 2010 and 2011 on Mac and Win
    Programming in Microsoft Visual C++ (Win), XCode (Mac)

  • What converter do I need to download for converting CR2 files into DNG?

    Used EOS Rebel T1i in camera raw setting. The Canon Camera Raw images will not open up because camera is not supported in Photoshop CS5 Extended, version 12.0.4 X64. Also tried to open by changing the the setting to Photoshop Raw but got a "Specified image is smaller than file" alert. When image opened, it was a grayscaled image full of noise. See below. What can I do to open these images, or to convert them?

    Your Canon EOS Rebel T1i  is supported and only requires ACR 5.4 or newer.
    See: Camera Raw plug-in | Supported cameras
    Since you have Photoshop CS5 you should have ACR 6.7, so either there is something wrong with your install of ACR or you are doing something wrong.
    Trying to open in PHOTOSHOP RAW is completely different than ADOBE CAMERA RAW.
    You need to use Adobe Camera Raw (ACR),
    Just forget that Photoshop Raw even exists.It does not do what you need to do to open your CR2 files.

  • Need conversion logic for the xml sending from legacy system ...!!!

    Hi Experts ,
    we have one requirement where in the legacy system ( Sender system) is sending .xml  file and PI needs to pick the file and send it to ECC Via IDOC AAE Receiver Adapter  to R/3  (SAP ECC) System .
    The problem is the  .xml file which PI receives is in a different format  which is shown below
    </tns:Header>
        <tns:Body>
            <esa:Payload>
                <esa:Header>
                    <PayloadName></PayloadName>
                    <PayloadVersion>1.0</PayloadVersion>
                    <PayloadCreated>2014-01-07T02:39:55.793Z</PayloadCreated>
                    <PayloadSize units="Bytes">432</PayloadSize>
                </esa:Header>
                <esa:Data>
                    <zcs:HUM xmlns:zcs="com.">
                        <Hum_Number>00393155965135748871</Hum_Number>
                        <Source_Storage_Location>9000</Source_Storage_Location>
                        <Destination_Storage_Location>0100</Destination_Storage_Location>
                        <Material_Number>000000000000004123</Material_Number>
                        <Batch_Number>321940071 </Batch_Number>
                        <Quantity>0000000096000</Quantity>
                        <Production_Version>A100</Production_Version>
                        <Hostname>POSPI000003</Hostname>
                    </zcs:HUM>
                </esa:Data>
            </esa:Payload>
        </tns:Body>
    </tns:Envelope>|]
    need help to  convert this  .xml into PI Standard xml  format ( i mean without esa,zcs, ..So that at PI the message gets passed  successfully without throwing  xml parser issue or xml well not formed error .)  .
    do i need to write any java code for this ?
    Please experts needs your suggestions here .
    regards,
    khan ,

    Hi Aziz,
    please make sure your pasted xml has  start and end tags
    <tns:Body> </tns:Body>.
    i don't think you need to change the external definition. make sure that you use xslt mapping first then message mapping.
    Regards,
    Muni.

  • I need all drivers for r007txlaptop running Windows 7 64-bit OS.

    For some reasons i have to use windows 7 64 bit os on my r007tx ,and i am not able to turn on wifi or bluetooth on it or anything for that matter. I have searched for the drivers over the internet, i found some files but it says the file is not compatible, maybe they were for the   32 bit os, i dont know. Would someone please post a link to all the drivers for 64 bit win 7 ? thatd b great.
    or atleast tell me how to find drivers for specific hardware for my laptop. Thanks.

    Jay
    Try this Wireless LAN & Bluetooth driver. Download them, save it to your laptop desktop.
    Then, first install WLAN , restart system after installation.
    Restart system.
    Then, install bluetoothndriver.  Restart system after installation.
    If above don't work, please provide Hardware ID of devices, an eg. is here.
    Regards
    Visruth
    ++Please click KUDOS / White thumb to say thanks
    ++Please click ACCEPT AS SOLUTION to help others, find this solution faster
    **I'm a Volunteer, I do not work for HP**

  • How do I convert complex images to 8-bit grayscale images?

    I made a fourier transform of a greyscale image and want save this pictures as greyscale pictures. I can see the picture on the monitor, but I can't get it converted.

    Just found the solution after a lot of trials.
    You do the fourier transform, use IMAQ ComplexFlipFrequency, extract the magnitude plane as an array,take the absolute value, divide by 620,000, multiply by 256, set all values greater than 255 to 255, convert to an unsigned integer array, convert to U8-image.
    I don't know why the magic number is 620,000. I found it by trial and error.

  • Need conversion rule for field PACKNR

    Hi all
    I am trying to insert PACKNR field from flat file to Data Base Table KONDP. I am getting the PACKNR field as 75 from flat file in order to upload it to data base table i need to Convert it in internal format IVPHv6g}0MZX08002hqR8m.
    How can i encode PACKNR 75 as  IVPHv6g}0MZX08002hqR8m?
    Regards,
    Aboli.

    Domain of PACKNR has a converion routine.
    Double click in table on dataelement of PACKNR and next double click on domain of this dataelement.
    Now you see exit routine, double click on this and you will get two routines:
    CONVERSION_EXIT_VHUPI_INPUT
    CONVERSION_EXIT_VHUPI_OUTPUT
    Edited by: Micky Oestreich on Jun 18, 2009 1:10 PM

  • Save U32 bit image as 16 bit tiff

    Right now I am using IMAQ to grab a RGB(U32) color image in real-time. I am then trying to save the image as a 16 bit tiff file. However, the images only save as 8 bit tiff files. How can I fix this problem?
    Thanks,
    David

    Hi David,
    The simple VI that I attached reads an image from file and writes it as a TIFF.  If you would like to test it, you can open up one of the images in the Vision >> Images folder (for example, candy.png which is U32) and you will see that it should save it as a U32 TIFF file.  If the image you are reading in is I16 (i.e. IMAQ Create has type I16 wired in as a constant) then you should get an appropriate image out.  If you are successful with this VI, I would recommend migrating it into your application.  I hope this helps give you a good start.
    Vu
    Attachments:
    Write TIF.vi ‏55 KB

Maybe you are looking for

  • Problem with USB audio device

    Hi all I have many problem with a USB device sound, i have a plantronic headset with a usb adapter to connect on my macbook pro, I have already this problem in the past but i have found a astuce to fix this problem. Before, when i'm on teamspeak 2, 3

  • Possible to create medium res .pdf file with InDesign CS5?

    Hello, Can anyone tell me if there is a way to create a medium res .pdf file with InDesign CS5? I'm working with a client and have been sending him both high res and low res files of a catalog project. High res .pdf is 12.8MB and low res is 1.2MB. He

  • Need informations about abap-hr

    Hi Guys, I need ebooks on ABAP HR. or some useful documents about abap-hr. Logical databases / Infotypes/Macros..etc Anybody can send me . It's important. Thanks

  • Lumia 1020 not getting Black update

    I recently bougth a brand new lumia 1020 with firmware version 3049.0000.1330.1002 so when will I recieve this update

  • Question about Hibernate non-automatic id generator

    Hello I have a small problem which I cannot fix. I insert an object into the database which has a fixed ID that is entered on the website. Hibernate adds this perfectly, all goes well. But when i try to edit (through session.update()) it will not cha