How to convert color image(24 bit) YUV 4:2:2 to gray scale 8 bit image

I am using sony DFW-X700 color camera for one of vision applications.Does NI Compact Vision System(CVS) support YUV 4:2:2 format(8 bit each).I want to do gray scale processing, so i need to convert the YUV color into gray scale (8-bit) in the software(like Labview). Please suggest us how to do this conversion for better gray scale image clarity from color.

In YUV color space, Y represents the gray scale; in RGB color space, R=G=B represents gray scale. You can simply set R=G=B=Y, to convert YUV to RGB. If the original color depth is 24 bit, then the result is 24 bit too.
You can create gray scale color table like this:
array size = 256;
[0] = 0x000000;
[1] = 0x010101;
[2] = 0x020202;
[255] = 0xFFFFFF;
To convert 24 bit gray scale to 8 bit, check every pixel in 24 bit image to find the array index according to the color table, and replace the pixel with array index.
George Zou
http://gtoolbox.yeah.net
George Zou
http://webspace.webring.com/people/og/gtoolbox

Similar Messages

  • How to create an gray scale png image from intensitie​s values

    Hi,
      I would like create a gray scale png image from set of intensities values which is saved in excel sheet . Is IMAQ tool necessary for this vi?
    thanks & regards
    Manoj

    You posted in the feedback forum, which is not correct for your question. I am guessing you are talking about LabVIEW since you mention "vi".
    manojkp89 wrote:
    Is IMAQ tool necessary for this vi?
    The answer is NO. Plain LabVIEW is sufficient.
    LabVIEW Champion . Do more with less code and in less time .

  • Gray scale photos images are different but should be the same; help?

    I send a gray scale image from Lightroom (Edit with ...) and it opened CS4 photoshop.
    I made a blank document , 11x14".
    I used Windows/arrange/ tile to view the blank and the gray scale image. I tired various methods of bringing the gray scale image to the blank one (move tool, select all and move, copy and paste). Each time, I did this within seconds of each other (I made no changes to fill, opacity, and I used Normal). I brought the image in twice so I could print out the SAME image twice on the larger 11x14 at Sams club in order to use the Epson 7800 printer and not the old wet process on the Fugi machine. One image is darker(lighter) than the other every time. I even tried another image and I got two different exposures.
    I wonder if it it only happens with the grayscale images? Perhaps it is a problem coming from Lightroom 2.5?
    I did a three image 16x20 and I didn't notice the difference - partly because they were three differenct images in color. I will try two color images from the same file tomorrow.
    Any thoughts? I haven't found a possible setting problem that would have been applied between the operations.
    Rich

    Paulo,
    Thanks. I was ready to believe the monitor idea but I still have some reservations.
    I don't doubt what you said about the pixels (sounds correct to me).
    Why?
    I tried another monitor and the images I attached also look like the top one is darker (vertically).
    Also, the same is true if I scrolled the images. It seems to me that I should see a difference as I slowly scroll the image vertically. I didn't see a difference.
    Read on please.
    At any rate (I long for a CRT - my 21" crapped out last year), I am using  two SAMSUNG screens, the
    one attached to the main computer is the Syncmaster T220 - a well rated
    monitor; as far as I knew , read and had friends who recommended them.
    The other I just tried is attached to the second computer a couple of feet away. It is the syncMaster T240HD. 
    So, if it is an LCD monitor problem, it is with both and the same
    company. I would think I would have read some bad reports about these
    LCDs?
    Also, wouldn't the color images also be different when presented the same way? (they aren't).
    However, I went back to the original T220 LCD display and moved an image in to a blank one as before, then did the control J to copy the layer, and the images we different again. But, I zoomed in more than usual and scrolled the images and they were lighter at the bottom of the screen and darker at the top of the screen!!!!!!
    That is good news and bad news! $$$$$$
    If it is the monitor problem, then both images should print as the same.????
    Secondly, the display (LCD) attached to the machine at Sams showed the same difference between the two images. AND, I recall that the display is also a Samsung (I will check that tomorrow).
    What a bunch of coincidences! I guess I have to search the web for some Samsung answers? and contact the company?
    I want to explore as much on my end as possible.
    Hunt and another suggested the Control-J to avoid the problem by copying the layer. That didn't work either.
    I suppose I could tweak one of the images after bringing them in but I don't know how (I clicked the layer and I wasn't able to do anything - like lighten that image).
    Again, thanks for the help. I think the question maybe answered.
    I will send the screen capture shortly.
    Rich

  • How to convert color of bitmap image?

    I am programming with Acrobat 7.
    I'd like to change color of all object to CMYK color or gray.
    In case of plain object like path or font,
    I need to seek CMYK color from the object's RGB color.
    and I change the property of the object color space and value with it.
    but in case of bitmap image, i don't know how to at all.
    it has numerous colors.
    I hope your advice.

    Thank you both of you.
    by the way, Leonard, Could you tell me that APIs more detailly?
    I have look into the document for long time. it is still hard to find proper API.
    I have to say this again. I am trying to find APIs based on version 7.
    I am using custom function ACEconvertColorProfile which is placed in snippetrunner. it consists of these APIS ACMakeColorTransform, ACApplyTransform, and so on.
    but I can't find the way to convert bitmaps once and for all.
    I hope you give more hint.
    Thanks again.

  • How to convert color tiff into black and white?

    Hey guys, am new to JAI and need to convert a color tiff into black and white, I've gone through google and developed following code.
    img = JAI.create("fileload","C:/eosimias.tif");
                   newColorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_GRAY),new int[] {8},
                             false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
                   pb = new ParameterBlock();
                   pb.addSource(img);
                   pb.add(newColorModel);
                   img2 = JAI.create("ColorConvert", pb);
    frame = new JFrame("Tiff study");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.add(new ScrollingImagePanel(img2, 400,400));
              frame.pack();
              frame.setVisible(true);When I execute the following program I get the following error
    java.lang.IllegalArgumentException: The specified ColorModel is incompatible with the image SampleModel.
    on the line frame.add(new ScrollingImagePanel(img2, 400,400));can someone please help me out with it.
    Thank you in advance.

    Check under Image> Mode and select 8 Bits / Channel  first.
    Cheers,
    Neale
    Insanity is hereditary, you get it from your children
    If this post or another user's post resolves the original issue, please mark the posts as correct and/or helpful accordingly. This helps other users with similar trouble get answers to their questions quicker. Thanks.

  • How to scale an image displayed on JButton

    Hi all,
    I has a panel contains 42 buttons of the same size arranged with GridLayout manager. I try to display some images on the buttons. But the problem is that the image bigger than buttons. Is it possible to scale the image to fit the size of button and which method is used?
    Thank you very much in advance.

    Hi,
    I try your tips. But I still see no changes.
    here is the code. I wonder where I go wrong.
                    Image i=Toolkit.getDefaultToolkit().getImage("red.JPEG");                    i.getScaledInstance(-5,5,Image.SCALE_DEFAULT);
                    //or i.getScaledInstance(10,1,Image.SCALE_DEFAULT);                          
         ImageIcon ic=new ImageIcon(i);
                   button1.setIcon(ic);//add image to the button
        

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

  • How do I convert color image to color vector?

    Hi,
    Im fairly new/not very well versed in Illustrator, I was wondering if you guys could help me with instructions or tips how to convert old alphabet art to color and actualy converting color images like drawings to vector . Ive tried image trace but it turns the image black and white and with really rough strokes.
    Thank you!

    Is this art in the Public Domain? Or, do you have the copyright owner's permission to use it in your work? If the answer to both of these questions is no, then you should not be using it.
    That being said, I got good results with image trace (using the High Fidelity Photo preset) even on the low-res image you attached here. You just have to adjust the preferences after you do the trace.

  • How to Convert FLIR Gray Scale Image to a Temperatur​e Map in NI VBAI

    I have been working with a FLIR A315 Infra-Red camera and NI's VBAI software.  I need to determine the presence and continuity of a hot mastic foam that has been injected into the hollow bulb of a rubber weatherstrip seal in 4 adjacent locations that flow together inside the weatherstrip bulb to form a continuous foamed mastic plug.
    So far, I have been able to trigger image acquistions in VBAI from a FLIR IR camera by monitoring an Allen-Bradley PLC's status bit.   The communication with the FLIR A315 camera is via the IMAQdx GigE driver.  However, I haven't figured out how to detemine the temperatures from the gray scale images I receive from the FLIR camera.  I wonder if someone could give me some pointers on how to do this.
    I have attached some images below to illustrate what I am working with and how far I've gotten.
    iPhone_Photo.jpg - shows a photograph of the weatherstrip section that the FLIR IR camera is "looking" at.
    FLIR_IR_Monitor.jpg - a screen capture of a FLIR IR monitor utility that shows temperatures measured at a number of points and areas (showing it can be done)
    NI_VBAI.jpg - part of my VBAI 2010 project which shows the image I've acquired from the FLIR A315 IR Camera
    So, I am part of the way there, but so far have not found a way to map the gray scale image that VBAI is acquiring from the FLIR IR camera into a heat map from which I can determine temperatures - and would appreciate some help on how to do this.
    Kind regards,
    Nick
    Solved!
    Go to Solution.
    Attachments:
    iPhone_Photo.jpg ‏239 KB
    FLIR_IR_Monitor.jpg ‏113 KB
    NI_VBAI.jpg ‏205 KB

    Hello,
    Image provided by FLIR camera are unsigned 16bit.
    Depending on the FLIR temperature scale you selected (10mK or 100mK), you will have to divide by a 10 or 100 factor to get K values. Don't select radiometric output.
    So if your object is cold, the population of the histogram of your image will be on the left part of it and if the object is hot, the population of the histogram will be on the right part.
    If you want your temperature values in Celcius, just add 273,15 to the Kelvin Value.
    Then you can add a color palette in VBAI (FLIR iron is available)
    Hope this helps

  • How to best color correct image

    Hi,
    I earlier asked a question whereas I was having problems with color consistency from PS to ID. After resolving that I've run into another issue:
    In trying to figure out a way to put an image in ID in a specific set of red cmyk numbers. I've come up with two solutions, but each has a set of problems. Both are CMYK.
    The image on the left is a flattened black and red image (halftone) tif from Photoshop (the filter used flattens it). IT looks pretty god but If I try to adjust it with the correct red numbers, the black isn't neutral and gets a color cast, or I'm afraid it will in the printing process.
    The one on the right is a black and transparent tif from Photoshop that has been place over a red background (already in ID). Why does this 2nd one appear to be greyed?
    (I think I need to learn to fine-tune the color correction on the left one, but not sure which controls to use).
    Thoughts?
    No sooner did I post this, I read about someone else talking earlier about using the Multiply effect ( I didn't realize you could do this in ID), I tried it  and got a more integrated image which is what I wanted. Neat. Now, are there any printing repercussions during the printing process with this effect that I need to worry about, or WYSIWYG? ( I still need to tweak the contrast I know, but at least the red is right.)

    I just wrote a huge, even more convoluted post trying to answer your questions, which I'll save for later because it may be moot. I'm thinking aloud here to try to clarify:
    We'er talking about 2 issues here, the greyness of the blacks and how they look on the surface and the color cast that may occur, is that right?
    Let me say that I initially used a 3rd party filter called "Ghost" (can only be used on RGB images). I use it on B&W images as well as color. That takes out all white information and leaves all transparency in various densities. Only a solid black has no transparency. Then I converted to Robin's SWOP Heavy. She is using black & white photos, not transparent images.
    Then came along your process.
    I took those images that were over cream (in Robin's workflow...I didn't see anything wrong with these images intially), then put them over red and sure enough got that greyed-out look, which is only noticable over red, but if I use them may show up in print that way, which leads me to believe I need to use your process, as the quality of the blacks needs to be consistant.
    Left is Robin's profile, right side is with "Multiply" applied. Which leads me to believe that I need to re-do all my images as per your ideas. I thought black would be black. Guess not.  I'm not sure if the end result of using your process is the same as using multiply or not but it looks the same and is consistant.
    All that being said, what again should be my images profiles and ID file be?
    this is what they are, ..and I thought they were Blurb's but I screwed something up there too...
    Images..don't remember If I need to convert!!? I think so then what's the point? UGH:
    ID file:

  • How to convert RAW images to JPG in Imagebrowser EX 1.4.0.5

    I installed ImagBrowser EX so I can view my raw images.  It works fine for viewing but I can't find how to convert them to raw images.  The manual and help file says to go to Edit > Process RAW Images but when I go to the edit menu, there is no such option.  There is only Correct red-eye, auto correct, adjust color and brightness, increase sharpness, crop imae, insert text, edit movies and extract multiple images from movie
    Help?

    You need to install Canon Digital Photo Professional from the camera-supplied CD.
    John Hoffman
    Conway, NH
    1D Mark IV, Rebel T5i, Pixma PRO-100, MX472

  • How to convert sRGB images to CMYK retaining icc profiles?

    I was given the follwoing info. but not sure it answers fully - it still doesn't resolve the problem of converting to CMYK with the icc profile. I think this might be an option if the profile is loaded into the colour setting (colour settings under edit menu as oposed to convert to profile and its convert to profile I have been trying to action. Am I missing something straightforward?
    thanks!
    you can do batch process in Photoshop
    http://help.adobe.com/en_US/photoshop/cs/using/WSfd1234e1c4b69f30ea53e41001031ab64-7427a.h tml
    -There is a fast and easy method to batch convert many RGB photographs to CMYK files by using Photoshop
    -Please open an image, then open the Action Tab (Window > Actions)
    -Please click 'Create new action' button, name the action in the text field and click the 'Record' button.
    -Now it is recording, so select 'Image > Mode > CMYK Color', then hit the 'Stop' button in the Action Tab.
    -The action is now created ready for the next step.
    -To batch convert a folder of images, just select 'File > Automate > Batch' and the following window opens.
    -Choose the 'Convert RGB to CMYK' action from the drop-down list, choose the source folder where your images are stored, then choose a destination folder where Photoshop will save the converted images.
    -Click the 'OK' button and the batch process will start. How fast will depend on the number of images that need converting.
    -The action you created will be stored, so you only need to perform a new batch process the next time you need to convert a batch of images.

    I think we may need a little more information to fully address your question or issue.  sRGB and CMYK are two very different color spaces, and converting from one to the other requires significant shifts in color.  Are you refering to a specific input or output icc profile?

  • How to preflight a convert colors command

    I can manually convert color spaces per the attached screenshot, but for the life of me I can not figure how to turn this into a batch or preflight in Acrobat 9 or an action or preflight in Acrobat X.  Can someone please help me with this and explain how this can be done?  I can manage to convert the text and lines but the images are not converting like they do when I run it manually.

    I can manually convert color spaces per the attached screenshot, but for the life of me I can not figure how to turn this into a batch or preflight in Acrobat 9 or an action or preflight in Acrobat X.  Can someone please help me with this and explain how this can be done?  I can manage to convert the text and lines but the images are not converting like they do when I run it manually.

  • How can you color-manipulate a .tif image?

    I am working on a project from an already-existing idd file, and am just needing to update it for a client.  While in the file, I noticed something that I didn't think was possible!
    There is a linked black and white .tif image that has somehow been colorized.  The attached image above is the resulting "texture" background created with the linked image. 
    I can't figure out how this was done.  Anyone know?
    Thank you!

    In my usage, the image cannot have a transparent background?
    In CS6+ the grayscale can have layers and transparancy, but there has to be a Background layer with no transparency. So this layered PSD with a transparent layer over the background works:
    But if the background is converted to Layer 0 with transparency it doesn't

Maybe you are looking for

  • Middleware: Change sales order status

    Hi, I am trying to change the status of a sales order within the middleware. For manupulation of the data I use a custom implementation of 'CRM_DATAEXCHG_BADI' and there the interface 'CRM_DATAEXCH_R3D_MBDOC_FILL'. Is interface is called after the MB

  • I don't know where to start............

    I'm horrified at the treatment I have had, all I wanted was to move home and I have been treated like an idiot, my BT move was cancelled and nobody at BT can tell me why, I had to sign up as a new customer, I was guaranteed my original (40 year) phon

  • How to retrieve updated payload information from completed HumanTask

    after initiating the HumanTask , updating the payload object from java client api payload information set into task object. taskService.updateTaskOutcome(workflowContext, task, outcome) ; after this call the HumanTask will be Completed. Now i tried t

  • Trigger_stack_index

    Help, On a table I have implement the Utility to Maintain database triggers to circumvent mutating table restriction. Unfortunally when I update the table then the PUSH_xxx_ROW (xxx is the prefix of my table) will cause an application error : raise_a

  • How to write a file into UNIX!

    Hi Group! I am trying to write an error file into UNIX directory using 'OPEN DATASET ERRFILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT'. But unfortunately i am getting a dump as it is giving the subrc 8 and dumping with CX_SY_FILE_OPEN_MODE. The path