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?

Similar Messages

  • 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

  • How can I convert an array to image(8bit)

    I can convert an array(acquire from usb camera)to a picture,but not images(8 bit grayscale),how can I do it.many thanks!
    Attachments:
    array to image.vi ‏249 KB

    Sorry, this is the kind of thing that happens when you have been out for too long.
    Message Edité par chilly charly le 10-22-2006 11:09 AM
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    array%20to%20image[1].png ‏3 KB

  • How to create an Average Image from Gray Scale (8 bits) JPEG Images

    I�m trying to create a mean image from 9 JPEG Images, but this mean image has lots of "noise", is distorced, and doesnt�resemble at all the original ones.
    I need this mean image so I�ll correlate each of the original ones to find out the best image I�m going to choose ussing NCC (normalized cross correlation coeficient).
    When I use setRGB(x,y,rgb), it returns diferent "images" according to the number of zeros, for ex.: rgb = 028028028 is different from 28028028 and from 282828. I can�t find a way to work it out.
    My algorithm is the folowing:
            File f;
            double [] [] pixels = null;
            Color [] [] tempPixel = null;
            Integer [] [] byte0 = null;
            Integer [] [] byte1 = null;
            Integer [] [] byte2 = null;
            Integer [] [] byte3 = null;
         Integer [] [] tempPixels = null;
            mean = null;
            int w,h;
            fileNames = new String[numFrames];
            for (int i=1; i<numFrames; i++){
                fileName = path + "Frame#" + i + ".jpg";
                fileNames[i-1] = fileName;
            // just for getting width, height, for configuring pixels array and
            // buffered images - mean & best.
            fileName = path + "Frame#8.jpg";
            f= new File(fileName);
            try{
                temp = ImageIO.read(f);
            }catch(IOException io){ return false;}
            w = temp.getWidth();
            h = temp.getHeight();
            mean = new BufferedImage(w, h, BufferedImage.TYPE_BYTE_GRAY);
         pixels = new double [w][h];
            byte0 = new Integer [w][h];
            byte1 = new Integer [w][h];
            byte2 = new Integer [w][h];
            byte3 = new Integer [w][h];
            tempPixel = new Color[w][h];
              tempPixels = new Integer[w][h];
            f=null; temp = null;
            //reset pixels values.
            for(int x = 0; x < w; x++){
                for(int y = 0; y < h; y++){
                    byte0[x][y] =0;
                    byte1[x][y]=0;
                    byte2[x][y]=0;
                    byte3[x][y] = 0;
                    pixels[x][y] = 0;
            // read each file (image), and according to W & H and collects the
            // pixels values.
            for(int j=0; j<numFrames-1; j++) {
                f = new File(fileNames[j]);
                try{
                    temp = ImageIO.read(f);
                }catch(IOException io){ return false;}
                if(temp!=null)
                    for(int x=0 ; x< temp.getWidth(); x++){
                    for(int y=0; y<temp.getHeight(); y++){
                        tempPixel[x][y] = new Color(temp.getRGB(x,y));
                  pixels[x][y] = pixels[x][y] + temp.getRGB(x,y) / 16581375;
                        //BLUE
                        byte0[x][y] = byte0[x][y] + (tempPixel[x][y].getBlue());//tempPixel[x][y].getBlue(); //& 0xff;
                        //GREEN
                        byte1[x][y] = byte1[x][y] + (tempPixel[x][y].getGreen());// >>8 & 0xff;
                        //RED
                        byte2[x][y] = byte2[x][y] + (tempPixel[x][y].getRed()); //>>16 & 0xff;
                        //ALPHA
                        byte3[x][y] = byte3[x][y] + (tempPixel[x][y].getAlpha()); //>>24 & 0xff;
                f=null;
            }//end of loop for j<numFrames
            String t0, t1, t2, t3;
            for(int x=0 ; x< temp.getWidth(); x++){
                for(int y=0; y< temp.getHeight(); y++){
                     byte0[x][y] = byte0[x][y] / numFrames;
                    if((byte0[x][y])<10)
                             t0= "0" + byte0[x][y].toString();
                    //else if((byte0[x][y])>=10 & ((byte0[x][y])<100))
                    //    t0 = "0" + byte0[x][y].toString();
                    else
                        t0 = byte0[x][y].toString();
                    byte1[x][y] = byte1[x][y] / numFrames;
                    if((byte1[x][y])<10)
                             t1=  "0" + byte1[x][y].toString();
                    //else if((byte1[x][y])>=10 & ((byte1[x][y])<100))
                    //    t1= "0" + byte1[x][y].toString();
                    else
                        t1 = byte1[x][y].toString();
                    byte2[x][y] = byte2[x][y] / numFrames;
                    if((byte2[x][y])<10)
                             t2= "0" + byte2[x][y].toString();
                    //else if((byte2[x][y])>=10 & ((byte2[x][y])<100))
                    //    t2 = "0" + byte2[x][y].toString();
                    else
                        t2 = byte2[x][y].toString();
                    byte3[x][y] = byte3[x][y] / numFrames;
                    if((byte1[x][y])<10)
                        t3="0" + byte3[x][y].toString();
                    else
                        t3 = byte3[x][y].toString();
                        pixels[x][y] = (pixels[x][y]/numFrames) * 16581375;
                    try{
                        String rgbs = t2+t1+t0;
                        Integer rgb = Integer.valueOf(rgbs);
                              //System.out.println("Valor do rgb: " +rgb);
                        mean.setRGB(x,y,(int)pixels[x][y]);
                    }catch(NumberFormatException nfe){
                        System.out.println("ERROR: Integer to STRING: "  + nfe);
                        return false;
                    }// end of catch

    It�s ok, I�ve already found the solution.
    Thanks.

  • How to convert an array of numbers into a time signal?

    I have an array of 512 data points. I want to convert this array into a time domain signal (the one with the brown color). How would I do this? Please let me know soon...Thanks!

    If you are referring to waveform data type, use the "build waveform" function as illustrated in the attached vi. Also check LabVIEW help waveform example for more sample vi.
    Attachments:
    sample_vi.vi ‏30 KB

  • Convert Bytes Array to Binary?

    Hi,
    I have an array of Bytes .
    How can i convert it into Binary format ?
    Regards,
    Gaurav

    You must be misunderstanding something. There is no special format called "binary format".
    Explain to us why you want to convert your array of bytes into "binary format" and what "binary format" means according to you - then we might be able to help.

  • How do I change my birthdate that was entered in on my Adobe App.  I want to convert images to pdf

    How do I change my birthdate that was entered in on my Adobe App.  I want to convert images to pdf

    What Adobe app?

  • I want to convert a String into an array of bytes

    I am working with telnet programming with java, where I want to convert login name and password of an online user in 'String' format to 'Bytes', plz help me. Which Input or Output Stream I can use

    Assuming you've got the username / password into a String object, you can convert it to a byte[] array using this method.
    String.getBytes();
    Look at the String API
    http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html
    Hope that helps.

  • Want to convert  tif image file into jpg image file , pls help me

    hey coders, i want to convert a tif image file into a jpg image file , can u all help in this

    In it's simplest form, it's two lines of code.
    BufferedImage bi = ImageIO.read(/*the tif file*/);
    ImageIO.write(bi,"jpeg",/*output file*/);Though, you need to install [JAI-ImageIO|https://jai-imageio.dev.java.net/binary-builds.html] read the tif file into a BufferedImage.

  • Pdf image whit text want to convert in  word

    pdf image whit text want to convert in  word

    Please post your question at this link:
    <https://forums.adobe.com/community/acrobat/creating__editing_%26_exporting_pdfs>
    And also explain better because an image is an image and it can't be
    changed to anything else but if you explain your requirements then
    somebody will come out with a solution for you.
    Good luck.

  • Convert byte array to table of int

    [http://www.codeproject.com/KB/database/PassingArraysIntoSPs.aspx?display=Print|http://www.codeproject.com/KB/database/PassingArraysIntoSPs.aspx?display=Print] Hello friends.
    I'm pretty new with PL/SQL.
    I have code that run well on MSSQL and I want to convert it to PL/SQL with no luck.
    The code converts byte array to table of int.
    The byte array is actually array of int that was converted to bytes in C# for sending it as parameter.
    The TSQL code is:
    CREATE FUNCTION dbo.GetTableVarchar(@Data image)
    RETURNS @DataTable TABLE (RowID int primary key IDENTITY ,
    Value Varchar(8000))
    AS
    BEGIN
    --First Test the data is of type Varchar.
    IF(dbo.ValidateExpectedType(103, @Data)<>1) RETURN
    --Loop thru the list inserting each
    -- item into the variable table.
    DECLARE @Ptr int, @Length int,
    @VarcharLength smallint, @Value Varchar(8000)
    SELECT @Length = DataLength(@Data), @Ptr = 2
    WHILE(@Ptr<@Length)
    BEGIN
    --The first 2 bytes of each item is the length of the
    --varchar, a negative number designates a null value.
    SET @VarcharLength = SUBSTRING(@Data, @ptr, 2)
    SET @Ptr = @Ptr + 2
    IF(@VarcharLength<0)
    SET @Value = NULL
    ELSE
    BEGIN
    SET @Value = SUBSTRING(@Data, @ptr, @VarcharLength)
    SET @Ptr = @Ptr + @VarcharLength
    END
    INSERT INTO @DataTable (Value) VALUES(@Value)
    END
    RETURN
    END
    It's taken from http://www.codeproject.com/KB/database/PassingArraysIntoSPs.aspx?display=Print.
    The C# code is:
    public byte[] Convert2Bytes(int[] list)
    if (list == null || list.Length == 0)
    return new byte[0];
    byte[] data = new byte[list.Length * 4];
    int k = 0;
    for (int i = 0; i < list.Length; i++)
    byte[] intBytes = BitConverter.GetBytes(list);
    for (int j = intBytes.Length - 1; j >= 0; j--)
    data[k++] = intBytes[j];
    return data;
    I tryied to convert the TSQL code to PL/SQL and thats what I've got:
    FUNCTION GetTableInt(p_Data blob)
    RETURN t_array --t_array is table of int
    AS
    l_Ptr number;
    l_Length number;
    l_ID number;
    l_data t_array;
    BEGIN
         l_Length := dbms_lob.getlength(p_Data);
    l_Ptr := 1;
         WHILE(l_Ptr<=l_Length)
         loop
              l_ID := to_number( DBMS_LOB.SUBSTR (p_Data, 4, l_ptr));
              IF(l_ID<-2147483646)THEN
                   IF(l_ID=-2147483648)THEN
                        l_ID := NULL;
                   ELSE
                        l_Ptr := l_Ptr + 4;
                        l_ID := to_number( DBMS_LOB.SUBSTR(p_Data, 4,l_ptr));
                   END IF;
                   END IF;
    l_data(l_data.count) := l_ID;
              l_Ptr := l_Ptr + 4;
         END loop;
         RETURN l_data;
    END GetTableInt;
    This isn't work.
    This is the error:
    Error report:
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    06502. 00000 - "PL/SQL: numeric or value error%s"
    I think the problem is in this line:
    l_ID := to_number( DBMS_LOB.SUBSTR (p_Data, 4, l_ptr));
    but I don't know how to fix that.
    Thanks,
    MTs.

    I'd found the solution.
    I need to write:
    l_ID := utl_raw.cast_to_binary_integer( DBMS_LOB.SUBSTR(p_Data, 4,l_ptr));
    instead of:
    l_ID := to_number( DBMS_LOB.SUBSTR (p_Data, 4, l_ptr));
    The performance isn't good, it's take 2.8 sec to convert 5000 int, but it's works.

  • 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

  • Pass an array of images???

    I am very new to java and my instructor gave us an assignment of doing a matching game using JButtons and an applet. I have 2 separate .java files (MemoryApplet.java and MemoryGame.java). MemoryApplet intializes the applet and passes an array of images to a method using the following code...
    icon = new MemoryGame();
    for(int i = 0;i<6;i++)
    imgArr[i] = getImage(getCodeBase(),"img" i".jpg");
    icon.setTheIcons(imgArr);
    In the MemoryGame file my setTheIcons method looks like this...
    public void setTheIcons(Image icon1[])
    The problem I am having is that I cannot convert the Image to an ImageIcon to put the image on the JButton. When I passed each image by itself not using an array, it worked fine, but I want to randomize the image locations so I thought passing the array would be the way to go. Any help would be greatly appreciated.
    Thanks, Chad

    If you want to use those images in JButton, so use the ImageIcon arrays like this:
    MemoryApplet
    // declare ImageIcon array
    ImageIcon[] imgArr = new ImageIcon[6];
    for(int i = 0;i<6;i++)
      // create new ImageIcon
      // path: path of images
      imgArr[i] = new ImageIcon(path + "img" + i + ".jpg");
    // initialize MemoryGame instance and call method
    icon = new MemoryGame();
    icon.setTheIcons(imgArr);Hope this help
    Liwh

  • How can I convert an array with varying length into a cluster

    Hi,
    I need to convert an array of n elements into a cluster. Usually, it only involves the "Array to Cluster" function. But since the array length is not constant and the number of elements in the function is constant and can not be changed programaticaly, I need to find another way to do that.
    Any ideas?
    Thanks.

    Hi,
    I also tried to do this but without success. I think that's not possible.
    For me it's a general problem using labview. I often wanted to generate standard controls dynamically which is not possible (or I haven't found the solution yet). So I think that's the reason why you can't create a cluster during runtime (the program would have to add controls dynamically to the cluster).
    Do you have an upper limit for your array-size? Although it needs a lot more memory, it would be a possibility to create the cluster with the maximum number of elements.
    If you don't have a maximum, you will have to look for another way, I'm afraid.
    Thomas
    Using LV8.0
    Don't be afraid to rate a good answer...

  • How to convert an array collection instance to a complex object for interaction with webservice

    Hi there,
    I have a stubborn problem that I am trying to work out the best way to solve the problem.  I am interacting with a WebService via HTTPService calling a method called find(String name) and this returns me a List of ComplexObjects that contain general string and int params and also lists of other Complex Objects.  Now using the code:
    ArrayCollection newOriginalResultsArray = new ArrayCollection(event.result as Array)
    flex converts my complex objects results to an arraycollection so that I can use it in datagrids etc.  Now up until this part is all good.  My problem is when getting a single instance from the results list, updating it by moving data around in a new datagrid for example - I want to interact with the webservice again to do an create/update.  This is where I am having problems - because these webservice methods require the complex object as a parameter - I am struggling to understand how I can convert the array collection instance back to my complex object without iterating over it and casting it back (maybe this is the only way - but I am hoping not).
    I am hoping that there is a simple solution that I am missing and that there is some smart cookie out there that could provide me with an answer - or at least somewhere to start looking. I guess if I have no other alternative - maybe I need to get the people who built the service to change it to accept an array - and let them do the conversion.
    Any help would be greatly appreciated.
    Bert

    Hi Bert,
    According to my knowledge you can use describeType(Object) method which will return an XML... That XML will contain Properties and values just iterate through the XML and create a new Object..   Probably u can use this method...
    public function getObject(reqObj:Object,obj:Object,instanceName:String,name:String=null,index:int=-1):Obj ect
                if(!reqObj)
                    reqObj = new Object();
                var classInfo:XML = describeType(obj);
                var className:String = instanceName;
                if(name!=null)
                    className=name+"."+className;
                if(index!=-1)
                    className=className+"["+index+"]";
                for each (var v:XML in classInfo..accessor)
                    var attributeName:String=v.@name;
                    var value:* = obj[attributeName]
                    var type:String = v.@type;
                    if(!value)
                        reqObj[className+"."+attributeName] = value; 
                    else if(type == "mx.collections::ArrayCollection")
                        for(var i:int=0;i<value.length;i++)
                            var temp:Object=value.getItemAt(i);
                            getReqObject(reqObj,temp,attributeName,className,i);
                    else if(type == "String" || type == "Number" || type == "int" || type == "Boolean")
                        reqObj[ className+"."+attributeName] = value; 
                    else if (type == "Object")
                        for (var p:String in value)
                            reqObj[ className+"."+attributeName+"."+p] = value[p];
                    else
                        getReqObject(reqObj,value,attributeName,className);
                return reqObj;
    Thanks,
    Pradeep

Maybe you are looking for

  • Ipod will no longer sync to Itunes ??

    My Ipod which Ive had for about 6 months has recently decided it will no longer sync to my Itunes so I cannot update the music. It recognises it is there and says it is syncing then comes up with the message 'The Ipod cannot be synced. An unknown err

  • Premiere CS5.5 linking to AE files

    Hi Everyone, I am still on 5.5 for another month or two until I wrap up with a client who is not upgrading.  I have a new project that I need to get done this week though, and I am having this weird bug.  When I go to import an AE comp in to my premi

  • Access JSTL variable outside JSTL tags

    hi I have this jstl tag: <sql:query var="brands" dataSource="${ds}"> select brand from carbrand </sql:query> i want to manipulate the brands.rowCount without using the <c:set var="count" value="${brands.rowCount}"/> how can I read the ${brands.rowCou

  • Thunderbolt Female Adapter

    Does Apple or anyone else make a Thunderbolt Female adapter to USB female adaptor.

  • Temporary Table issue

    Hi All I am using ODI 10.1.3.5 I have a requirement like the temporary tables created during interface execution should not be dropped . Instead it should truncate and kept it for next execution. I have used the option DELETE_TEMP_OBJECT to no in flo