Using conversion to array to add 16 bit grayscale images

Dear all,
Usual disclaimers, first post, tried to search using a variety of terms, no luck, so posting a new question!
I am trying to perform a running a verage of a 16 bit grayscale image. I do not have access to the Vision development module.  My 'workaround' is to grab the image, convert to array and then, using a shift register, to add this array to that acquired at the previous loop iteration. The problem I am having is that the shift register, despite being fed data in a 16 bit unsigned word formatt, returns 8 bit data. The add function is then trying to add 16 bit to 8 bit data and returns an empty array.
Can anyone help? Surely it must be possible to use shift registers with arrays of 16 bit data?
Any help appreciated!

Shift registers work with all datatypes. Can you show us your code?
LabVIEW Champion . Do more with less code and in less time .

Similar Messages

  • Display/save 8 bit grayscale image

    I have a VI that is capturing an 8 bit grayscale image (1D array of 1500 pixels). It has a 10 byte header that I strip off and try to display it.  The problem is that the displayed picture is interpeted as an RGB.  Also, the saved image can be opened using a picture viewer but is not correct.  It is missing the pixel data. How do I get this to display as an 8 bit grayscale image.  I would also like to duplicate the 1 row of image data to about 50 rows so that it is easier to view.  using a for loop and indexing the row only leaves the pxmao empty.
    Solved!
    Go to Solution.

    Bjoles,
    You are missing a colour table input to your flatten pixmap block. See the vi snippet I have attached. Also, I have found that building arrays from a for loop is a quick way of doing it, Labview seems to preallocate the memory correctly.
    Luke_A_P
    Attachments:
    build stripe.png ‏24 KB

  • How to create a 16-bit grayscale image from matrix of values

    Hello all,
    I'm having a problem converting a series of measurements into a specific image. I have a matrix of nxm dimensions (n and m variable), which contains measurement data. My intention is to transform this matrix into an image to be analyzed later on by an external software. The trick, however, is that the image has to be in 16-bit grayscale format: in grayscale for doing the image processing, and 16 bits to make sure that resolution is not hindered.
    I've been looking around the web and still haven't found a way of somehow mapping the measurement values I have in that matrix into pixels (16-bit grayscale ones, that is). I have access to the Full Development System version of LabView, but not other toolboxes.
    Does anyone have any suggestions?
    Solved!
    Go to Solution.

    Hi everyone,
    I've managed to get it to work thanks to some help from people on other forums. The key is to use the IMAQ driver, which gives the VIs necessary to create images on 16-bit grayscale (only supported nicely by PNG format apparently).
    The discussion on the other forum can be found here: http://stackoverflow.com/questions/11101420/structure-of-16-bit-grayscale-image-to-be-generated-in-c...
    The IMAQ driver can be found here: http://search.ni.com/nisearch/app/main/p/bot/no/ap/tech/lang/en/pg/1/sn/catnav%3adu,n13%3ahardwareDr...

  • Encode and Decode 16 bit grayscale image to jpeg2000

    i am trying to convert 10 bit grayscale raw image to jpeg 2000 using J2KImageWriter and i want it to convert back to grayscale raw image but when i am converting it it gives NULL.
    Here is my code
    public class Main {
    public static void main(String[] args) {
    if(args.length!=4)
    System.out.println("\nEnter imagefile height width header\n");
    System.exit(0);
    String filename=args[0];
    int height=Integer.parseInt(args[1]);
    int width=Integer.parseInt(args[2]);
    int header=Integer.parseInt(args[3]);
    try
    //reading the image data
    FileInputStream imagefile=new FileInputStream(filename);
    System.out.println("\nSize of image file:"+imagefile.available());
    System.out.println("\nHeader:"+String.valueOf(header)+" bytes\n");
    imagefile.skip(header);
    short pixels[]=new short[height*width];
    int i,j,k;
    k=0;
    for(i=0;i<height;i++)
    for(j=0;j<width;j++)
    int lsb=imagefile.read();
    int msb=imagefile.read();
    pixels[k]=(short)(msb<<8 | lsb);
    k++;
    //System.out.println(String.valueOf(pixels[i][j]));
    imagefile.close();
    DataBuffer buffer=new DataBufferUShort(pixels,width*height);
    SampleModel sm=RasterFactory.createBandedSampleModel(DataBuffer.TYPE_USHORT,height,width,1);
    Raster raster=RasterFactory.createWritableRaster(sm, buffer,new Point(0,0));
    //imagedata reading complete
    //conversion to jpeg 2000
    String outfile=args[0].substring(0,args[0].lastIndexOf('.'))+".jp2";
    File outimage=new File(outfile);
    ImageOutputStream imout=ImageIO.createImageOutputStream(outimage);
    J2KImageWriteParam j2kparam=new J2KImageWriteParam();
    J2KImageWriterSpi spi=new J2KImageWriterSpi();
    J2KImageWriter j2kwriter=new J2KImageWriter(spi);
    j2kparam.setLossless(true);
    j2kparam.setComponentTransformation(false);
    j2kparam.setEncodingRate(0.5f);
    j2kparam.setFilter(J2KImageWriteParam.FILTER_53);
    j2kparam.setNumDecompositionLevels(3);
    j2kparam.setWriteCodeStreamOnly(true);
    j2kwriter.setOutput(imout);
    j2kwriter.write(null,new IIOImage(raster,null,null),j2kparam);
    imout.close();
    J2KImageReaderSpi j2kspi=new J2KImageReaderSpi();
    J2KImageReader j2kreader=new J2KImageReader(j2kspi);
    ImageInputStream imin=ImageIO.createImageInputStream(outfile);
    j2kreader.setInput(imin, true, false);
    Raster decomp_raster=j2kreader.readRaster(1, null);
    int outputdata[]=new int[width*height];
    decomp_raster.getPixels(0,0,width,height,outputdata);
    FileOutputStream fileout=new FileOutputStream("decomp");
    for(i=0;i<height*width;i++)
    short temp=(short)outputdata;
    fileout.write(Short.valueOf(temp).byteValue());
    Short a=new Short(Short.reverseBytes(temp));
    fileout.write(a.byteValue());
    fileout.close();
    catch(Exception e)
    System.out.println(e.getMessage());
    Can anybody help me with this. Actually i need to study the performance of jpeg2000 compression using different setting of parameters.
    Thanks in advance.......

    Hi,
    I am able to encode and decode the image using J2Kwriter and J2Kreader classes. But now some other issue has came up.
    When compressed losslessly, the new jpeg2000 filesize is 415245 bytes. (My original file is of size 2000000 bytes)
    But when i am doing lossy compression, it results in following file sizes.
    Below 0.5 (encoding rate) - 535 bytes.
    Greater than or equal to 0.5 - 541 bytes.
    I tried with the following values of encoding rate - 0.1, 0.3, 0.5, 0.8, 1, 1000, 100000000, 500000000.
    I m not able to understand why i am getting the same filesize even with different encoding rate.
    How should i set the encoding rate parameter to achieve my target compression ratio.
    Kindly guide me. I will be very thankful to you.
    Preeti

  • Save an 16 bits grayscale image in a bmp file

    Hello,
    I need to save a bmp file using an I16 grayscale picture.
    I already did the following VI that saves the picture in bmp but the colors are not good : there is only blue levels.
    I think there is a problem with the type of data that feed "array to color image" or with the colorscale but i don't manage to find where.
    Hope you can help me.
    Tank you.
    Ben 

    Hi
    The arraytocolorimage expects U32 because expects a RGB color, try this instead of the "toU32"
    Rodrigo Cuenca
    www.cidesi.com

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

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

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

  • 16-bit grayscale

    Can Photoshop Elements work with 16-bit grayscale images?  I have version 10 and some of the tools don't work unless I make the images 8-bit grayscale.
    I asked this question earlier and had 50 views but no answers.
    Can you all understand the question?
    Scanning in 16-bit is easy enough with my Epson scanner and it might be useful if modifications are needed.
    But if Elements can't do it, must I upgrade to CS5 or something that's about 10x the cost?
    TIA
    Bandon Andy

    I assume you are scanning in 16 bits grayscale and creating a tiff format file.
    Several things to consider :
    - 16 bits choice: It's more important with grayscale images than with coloured ones. The risk is posterization (banding). Black and white editing requires much more contrast enhancements and tones stretching than colour editing. So, you are right to start with 16 bits scans.
    -16 bits editing in Elements. People tend to forget that the editor includes the ACR module which works natively in 16 bits and offers everything you need to avoid posterization effects and produce 90% of your editing before using the editor. All my work with black and white starts with 16 bits : not from scans, but from raw files. Even with 8 bits jpegs : as mentionned above, the heavy B/W editing would yield posterization in many cases. Working in ACR avoids the 'rounding' errors of the RGB values. Then, as you have seen, there are edits you can do in 16 bits in the editor : complete control of global tones and local contrast : levels, shadow/highlight, high radius USM, color curves, gradient map and many other filters. Those features are similar to what you can do in ACR, but with much more control. And there are things you can't do in 16 bits in ACR : working with layers and many local tools. For instance, the only way to select an area of the image is the lasso tool with its feathering option.
    On the other hand, you have to remember that your final device output (display, printer) is only 8 bits. For the very few professionals having 16 bits printers, they admit that you can't tell an 8 bits prints from a 16 bits one of the same image visually . It's critical to understand that once you have done all the editing at risk with posterization in 16 bits in an early stage, either in ACR or with the available tools in the editor, there is no quality advantage to work in 16 bits. All local tools and layers work can then be done in 8 bits with all the tools in Elements.
    - Choice of workflow. I am kind of a 'layers addict', but it's a fact that working in ACR (especially with the latest versions) I rarely need layers and my blend modes... In my experience, I can work in 16 bits in Elements without ACR, but now, in 90% of the cases, I don't even bother to 'open in the editor' in 16 bits.
    A few tips :
    Upgrading to PSE12 is recommended:
    - Much improved ACR editing
    - Ability to 'Open in ACR' several jpegs or tiffs at the same time from the editor
    - ACR ability to aplly the same editing settings to several pictures.
    - Why not consider adding quality plugins working in 16 bits ? I have smartcurves and the OnOne Black and white set. Less costly than the full Photoshop CS/CC.

  • To convert an rgb image to 8 bit grayscale

    Hey,
    I need to convert an rgb image to 8 bit grayscale image as the image is being acquired, im using the imaq create VI, which has an 'image type' terminal which allows the choice of image to be selected.however this isnt working. any solutions?
    also
    Im trying to make a image constant for the imaq subtraction VI, so the this constant image is subtracted from each image as its acquired.what would be the easiest way of doing this, without having the user specify the same image path each time? thanks.

    Not sure what you mean by extracting a plane?
    Here is a VI that will convert an image to 8-Bit.  This paired with the grayscale one will get the desired result.  See example.vi below.  Order that they are applied does give slightly different results.
    LV 8.0 through 2013, Win 7
    CLA
    Attachments:
    example.vi ‏12 KB
    QSI Convert to 8-Bit Image.vi ‏22 KB
    QSI Grayscale Image.vi ‏28 KB

  • How to create Image from 8-bit grayscal pixel matrix

    Hi,
    I am trying to display image from fingerprintscanner.
    To communicate with the scanner I use JNI
    I've wrote java code which get the image from C++ as a byte[].
    To display image I use as sample code from forum tring to display the image.
    http://forum.java.sun.com/thread.jspa?forumID=20&threadID=628129
    import java.awt.*;
    import java.awt.color.*;
    import java.awt.image.*;
    import java.io.*;
    import java.util.*;
    import javax.imageio.*;
    import javax.swing.*;
    public class Example {
    public static void main(String[] args) throws IOException {
    final int H = 400;
    final int W = 600;
    byte[] pixels = createPixels(W*H);
    BufferedImage image = toImage(pixels, W, H);
    display(image);
    ImageIO.write(image, "jpeg", new File("static.jpeg"));
    public static void _main(String[] args) throws IOException {
    BufferedImage m = new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_GRAY);
    WritableRaster r = m.getRaster();
    System.out.println(r.getClass());
    static byte[] createPixels(int size){
    byte[] pixels = new byte[size];
    Random r = new Random();
    r.nextBytes(pixels);
    return pixels;
    static BufferedImage toImage(byte[] pixels, int w, int h) {
    DataBuffer db = new DataBufferByte(pixels, w*h);
    WritableRaster raster = Raster.createInterleavedRaster(db,
    w, h, w, 1, new int[]{0}, null);
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
    ColorModel cm = new ComponentColorModel(cs, false, false,
    Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
    return new BufferedImage(cm, raster, false, null);
    static void display(BufferedImage image) {
    final JFrame f = new JFrame("");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(new JLabel(new ImageIcon(image)));
    f.pack();
    SwingUtilities.invokeLater(new Runnable(){
    public void run() {
    f.setLocationRelativeTo(null);
    f.setVisible(true);
    And I see only white pixels on black background.
    Here is description of C++ method:
    GetImage
    Syntax: unsigned char* GetImage(int handle)
    Description: This function grabs the image of a fingerprint from the UFIS scanner.
    Parameters: Handle of the scanner
    Return values: Pointer to 1D-array, which contains the 8-bit grayscale pixel matrix line by line.
    here is sample C++ code which works fine to show image in C++
    void Show(unsigned char * bitmap, int W, int H, CClientDC & ClientDC)
    int i, j;
    short color;
    for(i = 0; i < H; i++) {
         for(j = 0; j < W; j++) {
         color = (unsigned char)bitmap[j+i*W];
         ClientDC.SetPixel(j,i,RGB(color,color,color));
    Will appreciate your help .

    Hi Joel,
    The database nls parameters are:
    select * from nls_database_parameters;
    NLS_LANGUAGE AMERICAN
    NLS_TERRITORY AMERICA
    NLS_CURRENCY $
    NLS_ISO_CURRENCY AMERICA
    NLS_NUMERIC_CHARACTERS .,
    NLS_CHARACTERSET CL8MSWIN1251
    NLS_CALENDAR GREGORIAN
    NLS_DATE_FORMAT DD-MON-RR
    NLS_DATE_LANGUAGE AMERICAN
    NLS_SORT BINARY
    NLS_TIME_FORMAT HH.MI.SSXFF AM
    NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY $
    NLS_COMP BINARY
    NLS_LENGTH_SEMANTICS BYTE
    NLS_NCHAR_CONV_EXCP FALSE
    NLS_NCHAR_CHARACTERSET AL16UTF16
    NLS_RDBMS_VERSION 9.2.0.4.0
    Part of the email header:
    Content-Type: multipart/alternative; boundary="---=1T02D27M75MU981T02D27M75MU98"
    -----=1T02D27M75MU981T02D27M75MU98
    -----=1T02D27M75MU981T02D27M75MU98
    Content-Type: text/plain; charset=us-ascii
    -----=1T02D27M75MU981T02D27M75MU98
    Content-Type: text/html;
    -----=1T02D27M75MU981T02D27M75MU98--
    I think that something is wrong in the WWV_FLOW_MAIL package. In order to send 8-bit characters must be used UTL_SMTP.WRITE_ROW_DATA instead of the UTL_SMTP.WRITE_DATA.
    Regards,
    Roumen

  • Convert 16 bit Grayscale tiff file to Bitmap

    How can I do a batch conversion of 500+ pics (in TIFF format) from 16-bit grayscale to bitmap in Photoshop?
    Thanks.
    Chris
    PS - I know how to change them manually (Image>Mode>drop to 8 bit and then to bitmap).

    Record an action that does this: "change them manually (Image>Mode>drop to 8 bit and then to bitmap)"
    Then use scripts > image processor to process the files, running your new action at the same time. !! Be sure to work on a duplicate set of images !!

  • Making 16 bit grayscale - a image in a color scale

    Hi,
    I want to show a 16bit grayscale image in a scale of a certain color (that means that instead of scale of between black to white i scale of black to a color eg. red)
    I have some image in 16 bit grayscale format, i need to add them together each by a diffrent color scale, to make one image.
    (I am taking images in a grayscale from camera that is connected to a microsope, and each image is taken with a diffrent color filter and i need to accumulate then to make one image).
    thx in advanced!

    hmmm, no, because you need reform the data from an array of three separate images into one image which each pixel reprsents the three image's pixels in color.
    ill try to add the files so you'll see it.
    do you have another idea for doing it more easly?
    Attachments:
    adding three grayscales images to one image in diffrent colors.vi ‏75 KB

  • Re-using the same array on the same page later

    i am using an array to write values to a text file, is there a way to re-use that same array on the same page... after the values has been writen to a file, clear the values and use it again(no need to re-size it), just use it again....

    Thanks. I have a text box that takes a project id and calls a method that gets the data from db and stores it in a vector than i am looping throught the vector and assiging the values to an array and writing each value to a text file. i want to add another text field on there and see if the user wants to pass another project id (passing two) so i have to re-use the arrays again if the text box is not null. don't i need to re-define the arrays again to use them?

  • I have always used Nero wav editor to add eq, add volume and noralize recordings....do I have that feature in premier elements? and if so, where do I find it?

    I have always used Nero wav editor to add eq, add volume and noralize recordings....do I have that feature in premier elements? and if so, where do I find it?

    Zillenwater said: You can export a FLIP video clip using Picasa 3, and then bring it into Premiere Elements. The video and audio will successfully come in.
    Thanks much - this worked very well and was so easy. After spending hours looking at a lot of different converters and getting nowhere, I spotted this solution.
    I used Flip avi files directly from the camera, copied them into a folder that Picasa 3 could find, and then exported them. They showed up in my /My Documents/My Pictures/Picasa/Exported Videos folder as Windows Media Files (.wmv). I brought my test files into Premiere Pro 1.5, previewed them, placed them in the timeline and rendered them. they looked good here, so I exported my movie and the video looks pretty good, considering it was from the Flip.
    Picasa did something that a dozen other conversion programs couldn't get right (or at least I couldn't find the right combination of codecs and settings). It's a relief, alright, and information I'm happy to share.

  • Change 8-bit binary image back to 8-bit grayscale

    Can some one help me please in NI vision how to convert the image back to grayscale after I did my thresholding by using 'IMAQ Local threshold' from a 8-bit grayscale to a binary image but the problem now I don't know how to convert it back. I need someone help thank you.

    I'm afraid I haven't got the toolkit installed on my machine at the moment
    If I remember correctly you don't need to convert the image at all. On the last vision project I worked on we did a colour capture with a camera, converted it colour to greyscale for certain part of the anaylsis, (other parts we just did on the colour image), and then when we had found the ROI, we drew rectangles and circles etc on the colour image so the operator could see in colour! (just make sure to open a image reference to work on if you do this...
    If you really want help, I would advise making a simple VI containing the basic principles of what you want to do - work from an image constant on the BD, then post it in this thread and people will be able to see where you have got to and give you a quick pointer much faster! (fewer files = easier to work with)
    James

  • Creating a 16-bit grayscale JPEG?

    I am trying to creat a 16-bit grayscale JPEG in Java. The code below will work for TIFF and it will also work for 8-bit grayscale JPEGs but not 16. When I do this it throws a run time exception saying I can only creat 1 or 3 banded images.
    What is my problem?
                int [] bits = {16};
                ColorModel colorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_GRAY),bits,false,false, Transparency.OPAQUE,DataBuffer.TYPE_USHORT);
                SampleModel samp = new BandedSampleModel(DataBuffer.TYPE_USHORT,width,height,1);
                Raster ras = null;
                Point p = new Point();
                WritableRaster WR = ras.createWritableRaster(samp,p);
                for(int x=0; x<width; x ++)
                    double intensity = (double)x * 65000 / (double)width;
                   // intensity -= 32500;
                    for(int y=0; y<height; y++)
                        WR.setSample(x, y, 0, intensity);
                BufferedImage test = new BufferedImage(colorModel,WR,false,null);
                RenderedImage ri = test;
                String filename = new String("JPEG/16Bitgray.jpeg");
                OutputStream out = new FileOutputStream(filename);
                JPEGEncodeParam param = new JPEGEncodeParam();
                float q = (float)1.0;
                param.setQuality(q);
                ImageEncoder encoder = ImageCodec.createImageEncoder("JPEG", out, param);
                encoder.encode(ri); 

    As far as I know notion of 16 bit greyscale images is not present in JPEG specification but its available in JPEG2000. At the moment JDK supports JPEG but not JPEG2000 (both ImageIO and Toolkit) and it does not try to convert images automatically.
    One possibility is to try JAI JPEG2000 ImageIO plugin (https://jai-imageio-core.dev.java.net/).
    Another option is to convert image to something that is supported by JDK (you can test it using ImageWriterSpi.canEncode()) and then save it.
    For instance:
       BufferedImage gray16;
       BufferedImage bi = new BufferedImage(w, h, TYPE_INT_RGB);
       Graphics g = bi.createGraphics();
       g.drawImage(gray16, 0, 0, null);
       ImageIO.write(bi, "jpeg", out_file);

Maybe you are looking for

  • A way to make multiple pages in LR?

    I'm switching to LR2 from Apple Aperture. I use Aperture to make my photo website on Mobile Me. Once I get to LR, I know you can make a webpage within but, can these webpages be updated or new pages added to the created website template? I understand

  • Split Panel as in Jdeveloper 11g

    Hey together, i got just a small Problem with split JSF page in 2 Panels like in Jdeveloper 11G. Is there any solution how i can split the page, but it must be vertical. Regards Arni

  • Email Photos Workflow

    I find myself emailing photos out of iPhoto fairly regularly. Usually a few at a time (3 - 30). Is there a way to have the photos load into the email other than inline? I would like to get iPhoto to process the photos in to a folder for attachment to

  • URL bar gone

    I somehow made the URL bar at the top of Safari disappear last night and I have no idea how to get it back. I've downloaded the new Safari, but it didn't change anything.

  • SPRUNVALIDATION without Flow/AccountDetail  Dimension

    Hi, Does the Validation Business Rule work in an Application that does not have a Flow Dimension? The log table does not indicate # record calculated, # records updated. Instead I get a vague message "SPRUNValid Version 5.0.508." thanks Agnes