Converting Gray Scale to RGB

Can anybody tell me how to convert a Gray Scale image to RGB image?
I have written a Code:
public BufferedImage convertToRGB(BufferedImage input){
ColorSpace RGBSpace = ColorSpace.getInstance (ColorSpace.CS_LINEAR_RGB);
ColorConvertOp rgbConvert = new ColorConvertOp (RGBSpace, null);
BufferedImage output = new BufferedImage (input.getWidth(), input.getHeight(), BufferedImage.TYPE_INT_ARGB);
return rgbConvert.filter (input, output);
But this doesn't seem to work.
please help me
thanx

Try this:
public BufferedImage convertToRGB(BufferedImage input)
ColorSpace RGBSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
ColorConvertOp rgbConvert = new ColorConvertOp(RGBSpace, null);
output = rgbConvert.filter(input, null);
return output;
}

Similar Messages

  • 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

  • Convert to Gray scale issue in spot color file

    Hi,
    I am having some problem in Acrobat X Pro on Convert to Gray Scale Preflight Fixup, but the same PDF file is working good in Acrobat 9.0 Pro for the same process.
    Even I tried with the error report, but there was no error details in that report.
    Please help me out to find the reason for that problem. The PDF file is having a spot color.
    Please find the RGB and converted Gray image
    Thanks in advance,
    Veeramani.M

    Kumararaja,
    You can upload you file  using any public/private FTP and then can embedd the link here.
    Or when you click on Edit (in your message division), you get a browse option in the bottom left cornet. That allows upto 8.9MB. The way i attached!!!
    BTW, what's the issue?
    ~Sandeep V.

  • How convert a color PDF File to black & white (gray scale...no color)

    How convert a color PDF File to black & white (gray scale...no color)??? creative cloud cs6... Acrobat etc

    Hi, just wanted to add my 2¢
    I've been in publishing over 25 years and live in Acrobat for making my final files. Currently with a newspaper.
    This is what we do:
    • Tool Panes > Print Production Window
    • Select CONVERT COLORS
    • Midway down under OUTPUT INTENT, check Convert Colors to Output Intent
    • In the associated drop down menu, I choose (because I'm printing on newsprint) DOT GAIN 20% – If you're working on better stock, choose a lower dot gain percentage.
    • Click OK – this will convert the file
    • Save
    Note: this affects the file you're working with. Make sure that you use this method on a COPY if you want to retain the original color version.
    I think if you compare my method to the Preflight method, you'll see a tighter contrast and better blacks. I've always felt the Preflight method left continuous tones a little muddy.
    Now if there was only a way to add that to ACTIONS...!

  • How to convert the graph to gray scale

    Hi
    I am using MS 1.1 version, I need to take the print of the graphs which is provided by NI. The problem here is that i need the GUI to show the graph in multicolor environment, but when i am going to print it on a paper, i should be able to convert into gray scale. Can you kindly suggest me what should be done to achieve this?
    Is there any features which present in MS which can help an user to decide this conversion at run time.
    Thanks & Regards
    Sandy

    Hi Sandy,
    I hope you are doing well today! What is MS? You should be able to use the invoke nodes of the graph controls to export an image and do some manipulations to it. Can you be more specific as to what you want to do and what kind of programs you are going to use?
    Adnan Zafar
    Certified LabVIEW Architect
    Coleman Technologies

  • Can aperture 3 convert a gray scale photo into a line drawing?

    can aperture 3 convert a gray scale photo into a line drawing?

    I have a B.F.A. degree in painting which educated me in the "history of art" with appreciation of the old masters. I agree with your statement that, "anyone mistaking photos converted to "line drawings, watercolors,or paintings" is simply ignorant" and that, "line art is to drawing what clip art is to painting."
    I appreciate your passion and love for keeping "visual creativity" true to its inherant nature. Expressing your views however, in regard to my question in this thread, is irrelevant to the question asked. I am not ignorant.  My question has nothing to do with the philosophy of art. You have no idea what project I have in mind for asking my original question. I suggest that perhaps you have chosen the wrong forum to express your views.  Sticking to the question asked, as the other participants have, has been most helpful to me and I appreciate their response.
    Thanks for your attention.

  • Want to convert an array to image in gray scale

    i have an image that i have read into the vi. using the draw unflattened pixmap , i have an array of numbers .after some mathematical computations on the array i should be able to convert the array back to the image. how can i convert from array to image.and then from image to gray scale?

    I am not sure what you are doing. Can you post a simple example program?

  • 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

  • Changes, or loss of quality when changing from Indexed Colour to RGB or Gray Scale?

    I am using a canon scanner 700 to scan old photographs and plans/maps for high resolution publication. The plans and photographs are both in colour and in bl/wh and grayscale. I usually scan in gray scale unless its an important, coloured plan.
    I am unable to scan through c5 for some reason. Its a 64 bit dell M4400, W7. All legal, all working fine.
    I use the program canon supplies (Canon MP Navigator EX 2.1) and choose grayscale, 1200 dpi. No problem so far. Output seems great when I open in photoshop.
    However, the files open in Indexed Colour mode, and not grey scale as I scanned them in.
    My questions are :
    a) why does it open in indexed colour mode?
    b) is there any loss of information if I simply change them into grey scale?
    I need the files in high res for professional publication in large format, but also for analysis of dimensions. So I cannot afford ANY transformation or loss of info.
    Hope somebody can help me out!
    All the best,
    Mads M. Nielsen

    I am using a canon scanner 700 to scan old photographs and plans/maps for high resolution publication. The plans and photographs are both in colour and in bl/wh and grayscale. I usually scan in gray scale unless its an important, coloured plan.
    I am unable to scan through c5 for some reason. Its a 64 bit dell M4400, W7. All legal, all working fine.
    I use the program canon supplies (Canon MP Navigator EX 2.1) and choose grayscale, 1200 dpi. No problem so far. Output seems great when I open in photoshop.
    However, the files open in Indexed Colour mode, and not grey scale as I scanned them in.
    My questions are :
    a) why does it open in indexed colour mode?
    b) is there any loss of information if I simply change them into grey scale?
    I need the files in high res for professional publication in large format, but also for analysis of dimensions. So I cannot afford ANY transformation or loss of info.
    Hope somebody can help me out!
    All the best,
    Mads M. Nielsen

  • How to print a downloaded color document in black or gray scale

    I have Adobe Reader 9; Windows Vista Home Premium; HP Officejet Pro 8000 Wireless printer.  I have downloaded a document that is pre-set to print in color.  I want to print it in black or gray scale.  I click on the printer icon for the printing pop up.  When I click on the Properties bar to make the request for black or gray scale, nothing happens.  What steps can I take to convert the pre-set color download to be printed in black or gray scale?  Thanks!

    I have only had the experience when I have downloaded a link from within an email to my Hotmail account when the download has already been set up in color.  To date, I have not had that problem with Word.       There are specifically two situations regarding two different monthly emailed newsletters.  This is through Internet Explorer 8; Windows Vista Home Premium.  (I will not use Internet Explorer 9.  It causes blocks for routine procedures, especially involving my Hotmail account--such as not being able initially to download a normal attachment or, if downloaded, not being able to print a normal download attachment.)     However, after I sent out my request for help, I switched to Mozilla Firefox and was able to print the "color" download in black right away because the Preferences bar responded as it should.  (Through Internet Explorer 8, regarding this particular link/download/attachment, the printing pop up had a Properties bar.  However, I am aware that, in some other pop up formats, there are both a Properties bar and a Preferences bar to choose from.)       I have Mozilla Firefox as a backup because, sometimes, I have to resort to it to download email attachments (whether black or color) coming from the east coast when they will not download through Internet Explorer 8.  (I am near the geographic center of the US.)     Thank you for your interest in my concern.  I will gladly accept any advice regarding being able to print an email attachment/link color download in black when using Internet Explorer 8!  Does it depend on how the link attachment is set up or what the link attachment is??
    [private data removed]

  • How to capture the gray scale photo

    Hi. I followed this (
    https://msdn.microsoft.com/en-us/library/windows/apps/hh202982(v=vs.105).aspx ) example to capture photos and also in gray scale but the sample doesn't capture the gray image, it only pumps the gray pixels to the Image control. How can I freeze these
    pixels in the Image control or capture it as a jpg? Thank you in advance. 

    I should have been more clear. Forgive me.  I followed that example and added all the functionality as in the example like the focus(auto and tap), the flash light ect and it works but when it comes to the grayscale: the example only streams the converted
    pixels to the image control. It does not "capture" the image. Somehow I have to stop pumping the grayscaled pixels to the Image control and then I want to save-send the "gray" image. What's the easiest way to do that? This is what I have
    so far:
    MyClient.DownloadStringAsync(new Uri("http://www.iclips.co.za/sign_in.php?username=Clint William Theron&password=k"));
    However, the username and password is empty on the server side. How do I add paramters and download the server's response? Thanks in advance
    I basically want to turn this:
    var values = new List<KeyValuePair<string, string>>
    new KeyValuePair<string, string>("username", un),
    new KeyValuePair<string, string>("password", pw),
    new KeyValuePair<string, string>("friends", friends),
    new KeyValuePair<string, string>("density", "high"),
    new KeyValuePair<string, string>("platform", "Windows Phone"),
    var task = DoPost_Sign_In_To_Server("http://www.iclips.co.za/sign_in.php", values);
    async Task DoPost_Sign_In_To_Server(string url, IEnumerable<KeyValuePair<string, string>> values)
    try
    var httpClient = new HttpClient(new HttpClientHandler());
    HttpResponseMessage response = await httpClient.PostAsync(url, new FormUrlEncodedContent(values));
    response.EnsureSuccessStatusCode();
    var responseString = await response.Content.ReadAsStringAsync();
    this.Dispatcher.BeginInvoke(delegate()
    if (responseString.Trim().StartsWith("Welcome to iClips. You need to delete"))
    MessageBox.Show(responseString);
    return;
    if (responseString.Trim().StartsWith("Welcome to iClips"))
    //this means sign up was succesfull
    //so now we signed in
    txtDebug.Text = "Sign In Successfull :-)";
    vibrator.Start(TimeSpan.FromSeconds(1));
    else
    MessageBox.Show("Network Error: \n" + responseString);
    signForm.Visibility = Visibility.Visible;
    signForm_Shadow.Visibility = Visibility.Visible;
    catch (Exception ex)
    MessageBox.Show("Network Error: \n" + ex.Message.ToString());
    signForm.Visibility = Visibility.Visible;
    signForm_Shadow.Visibility = Visibility.Visible;
    txtDebug.Text = "Try to Sign In >> again.";
    in to WebClient, because of the progress bar that can be bind to WebClient.

  • Image to gray scale - jdk 1.6

    Hi , I have been trying to convert an image to gray scale. Source image is gif and has some transparent area. same code if run on java 1.5 works great, Transparent area remains transparent after conversion. But on java 1.6 same code results in black area for transparent area. I have tried multiple methods. All results same.
    I have to run this code on server side, so can not use screen device related APIs.
    Any help would be great. Please help.
    Regards,
    Abhinav

    To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable that shows your present approach in converting to grayscale. For the image, preferably link to a web resource so that members here can run your program without modification.
    Also, you could search the net for "color to gray scale algorithm" where you will find many algorithms, some of which will undoubtedly provide you with a solution.
    db

  • Converting Gray to sRGB

    How does Photoshop CS3 convert from Gray to sRGB in Save for the Web? Every time I use Save for the Web with a Gray scale image, it makes it too dark. While trying to reproduce the results, I found that a Dot Gain of 30% matched its conversion the closest. Does Save for the Web assume a Dot Gain of 30% for the conversion? This would definitely be a very poor assumption if so. Currently, I have a Dot Gain of 15% in the Color Settings dialog box. As far as I can tell, there's no setting in Photoshop, or Save for the Web for that matter, to set these types of conversions; hence, the reason my Gray scale images are coming out too dark. Any help on how to alleviate this problem would be greatly appreciated.
    My monitor has been profiled accurately with Eye-One Match 3.
    Thanks in advance,
    Wade

    Thomas,
    You can do yourself that 2.2 gamma profile in Photoshop and save it as a very simple icc profile if, in Color Adjustments, you choose as greyscale working space a custom gamma of 2,2 then (before closing the dialogue window), you save that "greyscale as..." (don't forget to revert your color spaces after that!).
    Hope it helps
    Gustavo (Posted from the deep heart of Sunny Spain)

  • Gray-scale shifting between CS3 programs

    Recently I have been playing with making inkjet contact negatives for traditional printing and decided to build some gray-scale charts for testing.
    I built my first chart in Indesign as tints of K-values and exported to a jpeg. I opened the exported jpeg file in Photoshop. I measured all of the charts values in Photoshop was was surprised to see a 2-5% shift in values.
    Going back to the file I tried exporting as a PDF, reading the values
    in Photoshop I got the same 2-5% shift.
    Trying once again I exported as an EPS and opened the file in
    Illustrator. Reading the values in Illustrator I also found a 2-5%
    shift.
    Finding these value shifts I recreated the document again in Indesign
    as RGB black values. Exported via the different methods listed and
    Checked the values. Still had the 2-5% shifts in all the values.
    Trying again, I built a chart in illustrator as an RGB document with
    values of K. I copied the chart and pasted the information as pixels
    into photoshop. Reading the values everything seemed right on the
    money. But after checking each value on the chart some of the values
    were off. The values are correct in Illustrator but not in Photoshop.
    for example in this last file 20%K reads as 25%K, 25%k reads as 25%k,
    85%k reads as 86%k there are about 6 values that shifted.
    Anyone know why gray-scale values are not staying the same across the
    different CS3 programs?
    I have also tried the file on a friend's MAC with the same results.
    'b' Color Settings
    CS3 indesign Color settings are Engine: Adobe (ACE) Intent: Relative Colormetric, Working Spaces: RGB:ProPhoto RGB, CMYK: SWOPv2, black point compensation: checked
    CS3 illustrator Color settings are Engine: Adobe (ACE) Intent: Relative Colormetric, Working Spaces: RGB:ProPhoto RGB, CMYK: SWOPv2, black point compensation: checked
    CS3 Photoshop Color settings are Engine: Adobe (ACE) Intent: Relative Colormetric, Working Spaces: RGB:ProPhoto RGB, CMYK: SWOPv2, black point compensation: checked, Dither: checked
    Appearance of blacks in Indesign and Illustrator set to accurate (tried set to accurate and set to rich black same results)
    'b' system information
    Vista Ultimate 32bit SP1
    AMD 64X2 duel core 6000+ 3Ghz
    6GB 666mhz Ram
    NVIDIA Gforce 7600 256MB video card (1.75GB total with system shared ram)
    Primary hard drive: 500GB
    Hard drive 2: 400GB (system and photoshop paging files and lightroom catalog drive)
    Hdrive 3: 1TB (primary image storage)
    user control turned off
    system graphics set to performance
    Duel display
    Lightroom 2.1
    photoshop CS3

    Peter,
    I did try RGB color space in Illustrator with assigned K Values; I got a strange shift where most values were exact and some were shifted to a higher value. Unlike straight out of Indesign where the values were almost all increased by 2-5%.
    I know that Indesign doesn't do Gray scale profiles. I consider anything gray scale when it's a value of K or values of RGB (percents of 0R0G0B or 10R10G10B)If you have a chart built as percents of RGB or CMYK values you should see the same percents of RGB or CMYK values in photoshop or in illustrator, I get an increase of value by 2-5%.
    I have the same RGB and CMYK color space for all three programs so the values should be the same for all three. I'm viewing this as a value issue I'm sure I would find the same shifts in indevitual CMYK or RGB colors as well. (I'll try checking single RGB and CMYK values when I get a change to show the shifts there)

  • Gray scale color table

    I want to make a picture out of an 8-bit unsigned integer 2D matrix of data. I can successfully do that using the "draw unflattened pixmap" function. However, it requires a color map. If you don't wire the color map, it uses the default labview color map. I want to use a gray scale color map (numbers between 0 and 255 corresponding to colors ranging from white to black). I am not sure how to make this color map and implement it. I appreciate any help.
    Solved!
    Go to Solution.

    Jahan wrote:
    The problem seems to be solved this way. Although it seemed to work (I got a gray scale image), I am not sure if what I have done is technically correct (if there is a better way of doing it). If someone wants to comment on it, I would appreciate.
    Yes, this is technically correct (top). (Typically you can do it once, then right-click the indicator and "change to constant" and delete the loop code.)
    You might also flatten the rgb tool code to the diagram (bottom). This has the advantage that the entirel loop will be calculated once at compile time and internally folded into a constant so the loop actually never spins during execution of the program (See also). (Of course this particular loop is trivial and nothing to worry about, performance wise. ) 
    Message Edited by altenbach on 03-14-2009 09:57 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    greyscale.png ‏6 KB

Maybe you are looking for

  • HT1727 how do i share itunes library with new iphone device?

    I just bought a new iphone and set up new icloud account.  How do I share my itunes librbary with this device/account?

  • Anybody know how to get second monitor to display portrait mode on new quad

    Hi all, I have a G5 quad with a 6600 video card and 2 monitors. 1 is a sony 24" and the other a dell 20". I have them both succesfully running in expanded desktop mode, but I would like to set up my dell to display in portrait mode. I can set it up o

  • Planning layout

    Hi. Suppose, planning level contains characteristics product, company code and key figure sales quantity. Is it possible to create layout with the following structure?        01            A               B P1    **             **              ** P2 

  • Question - Resetting Interactive Reports on Different Pages

    Hi, I currently have 5 pages, each with an Interactive Report. Page 1 contains column links with filters to the other 4 pages. Once a user has clicked a column link with the relevant column filtered on the Interactive Report on the other page, the on

  • ChaRM: "Import Urg. Corrections from Other Test Systems"

    Dear all, we are using Change Request Management on Solution Manager 7.0 EHP1 with a four-system landscape: DEV - TEST1 - TEST2 - PROD We want Normal Corrections to go the regular way from DEV to PRD with a longer stay in TEST1 for major release test