How to convert for 1 bit image

dir sir;
i want to make a programe by it i want to upload image real image and then it converted it for 1 bit image ;
can i use java to do that?
and if soo what method and package and function helps me to do that .
if you can provide me with simple code i will be thankfull.
beast regards.

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

Similar Messages

  • 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!

  • 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!

  • How to display 16 bit image in VBAI custom inspection interface?

    I'm working with 16 bit grey scale images in VBAI. In configuration mode, there is an option on how to handle 16 bit display mapping, and it works very well to preview the effect of the different display possibilities. However, those settings do not carry over into inspection mode. In the custom inspection interface, if I right click on the image display area it also has an option for 16 bit image mapping, with a default value of "Full Dynamic". It allows me to choose something else, but if I save the custom interface and reopen it, the value always reverts back to "Full Dynamic" For the time being, I've worked around it by adding a vision assistant step to convert the 16 bit image to 8 bit, but I would really prefer to take this step out. Are there any tricks to getting the image mapping setting to work properly within the custom interface? Thanks, Jason

    I would not expect that to happen. I will investigate. In the mean time if you have LabVIEW you can export the custom ui and edit the block diagram in LabVIEW. Then you can add a property node for the image display control to set the 16 bit display mapping when the vi runs. Make sure to reimport this updated ui and edit the step that updates the custom ui to run the code when the step executes. I'll let you know what I find out about why it reverts when you try to set it from the editor in VBAI.
    Thanks
    Brad

  • How to convert 64-bit to 32-bit oracle 8.1.7

    We are planning to upgrade our O/S version from AIX 4.3.3 to 5.2
    The limitation is that AIX 5.2 and 8.1.7.4 64-bit are not certified. We are also running Oracle Financials 11.0.3 so we cannot upgrade to 9.2.X versions.
    Can anybody tell me how to convert Oracle 8.1.7 64-bit to 32-bit? ( before upgrading to AIX 5.2)
    Is there a performance degradation between 64-bit and 32-bit RDBMS?

    Javed, I suggest you open an iTAR with Oracle support. For one thing I believe you will need a different binary. You may already have the install CD since I believe we received both and choose 64 bit.
    HTH -- Mark D Powell --

  • Converting 10-bit image to RGB 24

    I am using the IMAQ 1409 board to acquire black and white image in 10-bit format. Using the vision software I am type-casting this image into an RGB image. Later am saving the images into an AVI file using VIs from developer zone. The images are saved as RGB 24 bit on the AVI file. Am I losing resolution/information when going from 10-bit to RGB 24?

    Carlos,
    During the conversion process, the 10 bit image is converted to 8 bits, which is the maximum grayscale range for an RGB image. You are losing some information, but it is likely that it is not significant. For most applications, 8 bit grayscale is adequate.
    Bruce
    Bruce Ammons
    Ammons Engineering

  • 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

  • How to convert 24bits png image into 8 bits image

    Hi,
    I have gone through some of threads in this forum on changing color bits. But, I still can find right way to change my image (24bits) into different color bits(8 bits). The reason i want to change the color bits because I am getting a GIF image from map server, convert it into PNG format then rescale then into size of mobile phone screen.The PNG image is really has large data length , so the it took a while to load the whole image on screen.
    Note : The following code is taken from few threads in this forum and i have modified it to suit my application.
    I have no idea about Java2d...any help really appreciated...Thanks in advance!!!
    My code is as follow:-
    public File Scale(int width, int height, BufferedImage ImgSrc)
         try
                   //BufferedImage bi = ImageIO.read(ImgSrc);
                   //int w = bi.getWidth(), h = bi.getHeight();
         //Image oldRescale = bi.getScaledInstance(i, j, Image.SCALE_SMOOTH);
         BufferedImage Rescale = rescale(ImgSrc, width, height);
                   //ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
                   //ColorConvertOp op = new ColorConvertOp(cs, null);
                   //Rescale = op.filter(Rescale, null);
         File outfile = new File("map.png");
                   ImageIO.write(Rescale, "png", outfile);
                   BufferedImage fromFile = ImageIO.read(outfile);
                   ColorModel cm = fromFile.getColorModel();
                   System.out.println(cm.getClass() + ", bits/pixel=" + cm.getPixelSize());
              catch(Exception e)
                   e.printStackTrace();
              return new File("map.png");
         public static GraphicsConfiguration getDefaultConfiguration()
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    return gd.getDefaultConfiguration();
         public static BufferedImage copyRescaled(BufferedImage tgt, BufferedImage src)
              Graphics2D g2 = tgt.createGraphics();
    int w=tgt.getWidth(), h=tgt.getHeight();
    hintForBestQuality(g2);
         g2.drawImage(src, 0, 0, w, h, null);
         g2.dispose();
    return tgt;
    public static Graphics2D hintForBestQuality(Graphics2D g2)
    g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
              RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    g2.setRenderingHint(RenderingHints.KEY_RENDERING,
              RenderingHints.VALUE_RENDER_QUALITY);
    return g2;
         public static BufferedImage rescale(BufferedImage src, int w, int h)
    int transparency = src.getColorModel().getTransparency();
    GraphicsConfiguration gc = getDefaultConfiguration();
    BufferedImage tgt = gc.createCompatibleImage(w, h, transparency);
    return copyRescaled(tgt, src);

    First, we need to be clear about what you're trying to do -- is it rescale an
    image or insure that the image is saved with a 8bit pixel depth? Or both? You are also
    using GraphicsConfiguration's createCompatibleImage, which is excellent if you are going
    to display the image immediately because it might be hardware accelerated
    or compatible with hardware format, but you mentioned mobile phone screens, so
    there is no advantage to using GraphicsConfiguration in that case, and if fact, it's
    probably changing your ColorModel when you're not looking.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import java.io.*;
    import java.net.*;
    import javax.imageio.*;
    import javax.swing.*;
    public class Example {
        public static void main(String[] args) throws IOException {
            URL url = new URL("http://java.sun.com/developer/technicalArticles/GUI/JavaServerFaces/fig2.gif");
            BufferedImage image = ImageIO.read(url);
            System.out.println("image's colormodel = " + image.getColorModel().getClass());
            BufferedImage rescaled = scaleAndConvertColorModel(image, 0.75, null); //GIF => IndexColorModel
            System.out.println("rescaled's colormodel = " + image.getColorModel().getClass());
            File png = new File("junk.png");
            ImageIO.write(rescaled, "png", png);
            BufferedImage fromFile = ImageIO.read(png);
            System.out.println("fromFile's colormodel = " + image.getColorModel().getClass());
            JPanel cp = new JPanel(new GridLayout(0,1));
            addTo(cp, image, "original image");
            addTo(cp, rescaled, "rescaled image");
            addTo(cp, fromFile, "png file image");
            JFrame f = new JFrame("Example");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setContentPane(cp);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
            Will rescale and convert colormodel if necessary.
            ColorModel == null => don't convert. May return src if suitable.
        public static BufferedImage scaleAndConvertColorModel(BufferedImage src, double scale, ColorModel cm) {
            int w0 = src.getWidth();
            int h0 = src.getHeight();
            int w = (int) (w0 * scale);
            int h = (int) (h0 * scale);
            ColorModel cm0 = src.getColorModel();
            if (cm == null)
                cm = cm0;
            if (w==w0 && h==h0 && cm.equals(cm0))
                return src;
            BufferedImage tgt = createImage(w, h, cm);
            Graphics2D g = tgt.createGraphics();
            if (scale < 1) {
                Image temp = src.getScaledInstance(w, h, Image.SCALE_AREA_AVERAGING);
                g.drawImage(temp, null, null);
            } else {
                hintForBestQuality(g);
                g.drawRenderedImage(src, AffineTransform.getScaleInstance(scale, scale));
            g.dispose();
            return tgt;
        public static BufferedImage createImage(int w, int h, ColorModel cm) {
            if (w <= 0 || h <= 0)
                throw new IllegalArgumentException("...");
            boolean alphaPremultiplied = cm.isAlphaPremultiplied();
            WritableRaster raster = cm.createCompatibleWritableRaster(w, h);
            return new BufferedImage(cm, raster, alphaPremultiplied, null);
        public static Graphics2D hintForBestQuality(Graphics2D g) {
            g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
            g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
            return g;
        static void addTo(Container c, BufferedImage image, String title) {
            JLabel label = new JLabel(new ImageIcon(image));
            label.setBorder(BorderFactory.createTitledBorder(title));
            c.add(label);
    }

  • How to convert an pdf image into a jpeg

    I just purchased export pdf and I'm trying to convert from pdf to word or ppt.  The pdf is an image / logo that I want to make a jpeg.  I used the export utility and keep getting random characters and not an image. I'm guessing it's looking for text.  Do I have the right utility?

    I don't see converting to Word as the right way to go if you want a picture.
    Instead, view in Adobe Reader as large as possible, take a screen shot, paste in PAINT.

  • How to convert JPEG - PNG images using java?

    Hi,
    Has anyone done this before?
    Can you provide me with a sample code or point me to the direction on how this can be done?
    Are there any existing Java technology that supports this?
    Most grateful. Thanks.

    It's should be easy using Java Advanced Imaging (JAI). Try this.
    import javax.media.jai.JAI;
    import javax.media.jai.RenderedOp;
    public class convert {
      static public void main(String[] args) {
        String inName = args[0];
        String outName = args[1];
        RenderedOp source = JAI.create("fileload", inName);
        JAI.create("filestore", source, outName, "PNG", null);
        System.exit(0);
    }

  • How to convert AviVideoFormat to  Image?

    Hello all,
    Anybody knows how can I do a conversion from AviVideoFormat to a BufferedImage to display?
    regards and hnaks in advance

    jp1963 wrote:
    Anybody knows how can I do a conversion from AviVideoFormat to a BufferedImage to display?
    regards and hnaks in advanceSince you were patient this time, I'll offer help.
    1) If you're wanting to simply display the video, just play it using a player.
    [http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/SwingJMF.html]
    2) If you're wanting to access the image for the purposes of like, overlaying graphics on it dynamiclly,
    [http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/FrameAccess.html]
    Will give you the ability to do that. Or just access the individual frames for whatever reason.

  • How to convert an embedded image to a bytearray

    I have an image like this
    [Embed(source="images/open_position.PNG")]
    public var OpenImage:Class;
    How can I convert this to a ByteArray?

    Hi,
    Your OpenImage class is a subclass of BitmapAsset, then you can retrieve the ByteArray by an instance of OpenImage. Here is the draft code (not tested):
    public function getByteArray( InputClass:Class ):ByteArray {
         var instance:BitmapAsset = BitmapAsset( new InputClass() );
         return instance.bitmapData.getPixels();

  • How to convert a CMYK image to pantone in Illustrator

    Is it possible to convert the CMYK raster image to pantone in illustrator.

    On Mon, 12 May 2008 22:37:41 -0700, [email protected] wrote:
    > Is it possible to convert the CMYK raster image to pantone in illustrator.
    I think you meant to post this to the illy group.
    Mike Russell - [advertising link deleted]

  • How to use a grayscale color model in converting a colored image

    how to convert a colored image into grayscale using :
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
    int bits[] = new int[] {8};
    ColorModel cm = new ComponentColorModel(cs, bits, false, false,
    Transparency.OPAQUE,
    DataBuffer.TYPE_BYTE);
    please only this method , i don't need the "bandcombine" method cause i need to know that i have exact 256 grayscale colors, thanx in advance.

    I went into mail preferences in the first place. I found the fonts and colors and picked the color I want but it doesn;t seem to be sticking?

  • How to convert PNG image to Vertor Image to make font on Mac

    Hi Mac People,
    I like to create a set of font, and I have made them in a image editing tool, I have FontForge downloaded but decide to use it to convert instead direct design them inside.
    So now I don't know how to convert the PNG image to vector image required by the FontForge, I read some post mentioned Ubuntu has utilities to convert, but I'm not sure OS X has that function too.
    Could anyone let me know how to convert PNG so I can create my fonts?
    If PNG can't, the software can export TIFF or jpeg or similar.
    Please help me, I need make them this few day.
    Thanks everyone for giving me a hand!

    take a look at:
    http://developers.sun.com/techtopics/mobility/midp/articles/picture/

Maybe you are looking for

  • Ms access exporter error

    Hi, I have the Ms access table .When i tried to migrate i got the error. First i created connection with oracle. Second i tried to export the data from ms access . I got the following error. Error #5 -XML Exporter Invalid procedure call or argument c

  • Help - making a movie and the file is jumpy

    I'm making a slideshow to show a group of 50 students tonight. I've never had this issue with iMovie before. I have iMovie '11 and OS Lion. The file is like it has scratch marks that appear at various times, whether it's a transition or just displayi

  • How to rectify a connection object if it was entered wrong in a premise

    Hi, Please guide me how can we rectify the cases where  connection object was entered wrongly in the premise. Thanks and Regards

  • Snow leopard keeps rebooting

    After the recent updrade, snow leopard (10.6.8), Snow leopars keeps rebooting ? Any suggestions as to what might be the cause 0 how to prevent?

  • Unable to enter keyboard shortcut preferences

    OK, I've received my new aluminum keyboard today. I connected it to my "old" (November 2006) iMac 20" 2.16 GHz and installed the Keyboard Software Update 1.1. I'm encountering the issue with non-working F3 and F4 keys, like (almost) everyone else, bu