Read image saved in binary file in Matlab

Hello,
I save images in binary file, in one file can be thousands of images, and I would like to read it in Matlab or in some other software.
So I would like to know if it's posssible and if so I would like to know what exactly I save, when I save image, and how image structure look like.
Thanks Eva

Hi Eva,
I have little knowledge of IMAQ, so I don't know your data type... sorry.
But in general you read the data in MatLAB. You save the image (only 1) 100 times in the same file. Each image is prepended by a I32 with the total byte count of the image. So that is one pointer for you.
What you could do is convert your IMAQ image into a LV picture control (this must be possible) and then convert it into a U32 2D-dbl and read this with Matlab.
Success Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas
LabVIEW, programming like it should be!

Similar Messages

  • How to read labview binary files in Matlab

    I would like to read Labview binary files with Matlab. I read some articles of the subject and I am more interesting in know how labview store this data into file. What is the format use by Labview to store this data?
    Any help is appreciated,
    Hernando

    The term "binary file" means that the data on disk is a (pretty close) duplication of the binary format of the data in memory.  For example, a String will appear as an array of Bytes that, if looked at with a text editor, would be "human-readable".  
    An I32 or U32 integer would take 4 bytes, but the order (or "Endian setting") can be Big-Endian or Little -Endian (and I won't confuse both of us by trying to say which is which).  Thus the number "1" would appear as four byte of 0, 0, 0, 1 or 1, 0, 0, 0.  Floating point (Dbl) also has an "Endian" consideration, but the numbers are encoded as a mantissa and exponent, with sign appearing somewhere.  However, if you get the Endian and precision (Sgl, Dbl, etc.) right, both MatLab and LabVIEW should be able to read each other's data.
    Be careful with Booleans.  It wouldn't hurt to do an experiment and see how many bits/bytes are used for simple Boolean data.
    One other "gotcha" -- in LabVIEW, you can prepend Array and String writes with a U32 that is the length of the Array/String -- you obviously want to take this into account.
    Something that I've found helpful when dealing (in both Matlab and LabVIEW) with "unknown" binary data files is to use an old-fashioned "binary editor", something capable of displaying a file as Text and Bytes.  Strings "stand out", and if they seem to be preceded with 4 bytes that are mostly 0 with one Byte more-or-less the length of the String (sign that String Length was prepended).  If you see a lot of byte data that look like they could be 2 or 4 byte integers, they probably are.  If they are four bytes of numeric data that have few zero bytes (i.e. if most of the 32 bits seem to be used), they may well be floats.  Make a guess at the format and write a short routine to read according to your guess -- do you get meaningful data?  Go ahead, be a Scientist, not an Engineer -- study the data, form a hypothesis, then design and do an Experiment and see if you need to reject your hypothesis ...
    Bob (Neuroscientist) Schor

  • Can TestStand open, read, write and close binary files?

    From a TestStand sequence, I need to open, read, write and close binary files. Does TestStand support this capability?

    Christine -
    In the past I have used the C/C++ Adapter to call directly into the CVI RTE functions. The CVI functions I have used are OpenFile, WriteFile and CloseFile. The functions are exported from the DLL as CVI_OpenFile, CVI_WriteFile, and CVI_CloseFile. I just had to make sure that on termination of the sequence, that the integer handle was properly released by calling the close function.
    If you are using LabVIEW, you could call directly into the low level VIs to do a similar set of operations.
    Scott Richardson (NI)
    Scott Richardson
    National Instruments

  • How to read binary file in Matlab

    "Hello all!
    Labview 7.0 has an example "Cont Acq to File (binary).vi" log the PCI 6014 card and writes the data to a binary file. How can I read that
    file in Matlab(6.5.0... R13)? Does anyone have a solution for this?

    Hello,
    Basically you can do it by saving the data in a file in MATLAB and reading it directly from LabVIEW, or vice versa. In MATLAB , the command "save" allows you to save the data in binary format (*.mat) or ASCII format. You also have an option of saving it in ASCII format using a tab delimiter between data points.
    There is a knowledge base which talks in detail about how to share data in between labview and matlab Import data from labview to Matlab and vice versa.
    Hope this helps. If not, please feel free to ask more questions.
    Good luck and have a great day!
    Koninika
    National Instruments

  • Reading objects from a binary file works but crashes LabVIEW on exit

    I've been hunting for the source of some crashes on LabVIEW exit and I was finally able to track it down to this. In my application I wrap measurements into objects that I stream into a binary file during the inspection. In another application I read the file again to browse and analyze the measurements. All this seems to work just fine except that the reading part causes LabVIEW to crash once I close the IDE. Built applications don't report any crashes but I am afraid if it might still cause some instability or unexpected behaviour.
    The snippet below represents the writing and reading scheme I use and with which I am able to reproduce the problem every time. I attached the project for testing it.
    Parts from the internal warning report:
    #OSName: Windows 8.1 Pro N
    #AppName: LabVIEW
    #Version: 13.0f2 32-bit
    DWarn 0xEFBFD9AB: Disposing OMUDClass definition [LinkIdentity "Class 1.lvclass" [ My Computer] even though 1014 inflated data instances still reference it. This will almost certainly cause a crash next time we operate on one of them.
    Possible path leak, unable to purge elements of base #0
     The full log is also attached.
    Notes:
    Remember: the reading works without any problems, the crash after LabVIEW exit is what I'm concerned about
    Seems to only happen with classes/objects—not the default LabVIEW Object, though
    Prepending array size or different byte orders make no difference
    The writing is time critical, the reading is not, in case you wish to suggest other options
    Has anyone else run into this? Should I be concerned for the built applications or can this be simply ruled as an IDE problem?
    Solved!
    Go to Solution.
    Attachments:
    test_project.zip ‏16 KB
    lvlog.txt ‏5 KB

    Right off, if you say you can read and write lv objects, try casting your object as a lv object before saving it. The lv object is the ultimate parent of all classes.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • An applet that has to read data from a binary file

    Hello,
    I'm writing a simple applet-based trivia game. I want to send the questions together with the applet class as a binary file (I first created an object for a single question, then had an array of questions, then serilaized it and called the file "question.bin").
    I can't get it work, though. Here is what I've done:
         File file = new File("questions.bin");
         try {
             FileInputStream fis = new FileInputStream(file);
             ObjectInputStream in = new ObjectInputStream(fis);
             questions = (Question[])in.readObject();
             in.close();
         catch (Exception exp) {
             layout.show(this, "errorMessagePanel");
             repaint();
         }Not only that it doesn't work, it doesn't even execute the catch part. What have I done wrong? How will I do it right?
    Thanks is advance.

    Oops, forgot to mention that I had put the applet class, Question.class and question.bun in a jar file and specified it as the archive in the applet tag.
    The problem seems to be that file in null even after File file = new File("questions.bin"); has been executed.

  • Read images from a jar file?

    Hello, I'm converting a 6i app to 10g. This app does a ton of read_image_file() calls to
    change GIF images on the screen based on user actions. In 6i the images are all stored on the local hard drive. The images are not icons for buttons, but images that appear in different locations on the screen.
    For 10g, is it possible to leave the images in a jar file and effectively read the images from that? Otherwise, I suppose I'm looking at using webutil functionality to download the jar file and unjar it into an images directory for reading from the client?
    Any best-practice scenario for this sort of thing?
    Thanks for any info,
    Gary

    We are migrating from 6i to 10g too. And I try to not use webutil. All my pictures (icons gif files) are in a jar file.
    Just make attention of the size of your pictures. The jar file is loaded when you launch the application (the first time, and after, only if the jar file has changed).

  • Read images from external jar file (Sun's Java L&F Graphics repository)

    Hi!
    I don't know how to read images from an external jar file. Sun has a Java Look and Feel graphics repository that contains a lot of good images that can be used on buttons and so on. This repository is delivered as a jar file, containing only images, and I want to read the image files from that jar file directly without including them inside my application jar file. The application and image jar files will be in the same directory.
    I have absolutely no clue how to solve this. Is it necessary to include the images inside my application jar file or is it possible to have them separate as I want.
    Would really appreciate some help!
    Best regards
    Lars

    Hi,
    There is two ways :
    1) Add your jarfile to the classpath.
    Use the class loader :
    URL url = ClassLoader.getSystemResource("your/package/image.gif");
    Image im = (new ImageIcon(url)).getImage();
    or
    Image im = Toolkit.getDefaultToolkit().getImage(url);2)If you don't want to add the jar to the classpath you can use this (under jdk 1.4):
    import java.util.*;
    import java.util.jar.*;
    import java.awt.*;
    import java.io.*;
    import java.awt.image.*;
    import javax.imageio.*;
    public class ImageUtilities {
         public static Image getImage(String jarFileName, String fileName) {
              BufferedImage image = null;
              try {
                   JarFile jar = new JarFile(new File(jarFileName), false, JarFile.OPEN_READ);
                   JarEntry entry = jar.getJarEntry(fileName);
                   BufferedInputStream stream = new BufferedInputStream(jar.getInputStream(entry));
                   image = ImageIO.read(stream) ;
              catch (Exception ex) {
                   System.out.println(ex);
              return(image);
    }I hope this helps,
    Denis

  • Reading and writing u16 binary file to a new file

    Hello all,
    a very simple thing that I just don't seem to be able to figure out. I have a file containing 1024bytes of unsigned 16bit words. I can read it successfully with the right value  being displayed. But then I try to write these values to a new file, I can no longer read the same value (in fact it's all grayed out 0) from the newly written file. The newly written file has the right size 1024 bytes, but I don't seem to obtain the right information. I made sure the endian are the same, little-endian.
     Attached is my basic VI, and the .dat file is the file containing the binary information. 
    I'm not using copy file because once I get this figure out, I'll need to append more of the Scan.dat file to one single file. 
    Thank you!
    Solved!
    Go to Solution.
    Attachments:
    read_write_binary_u16.zip ‏11 KB

    I would put some wait time between the write and the read.  It may be a good idea to actually close the file in between.
    I have a feeling that you may not have allowed enough time to actually have the file written out before you read it again.  That or since it is still open, the file pointer is at the end of the file and you are trying to read all the bytes starting at the end, which means you get nothing.
    Not sure of the exact issue, but those two things comes to mind.

  • Read characters in a binary file

    I have a file written in binary format, which does not contain data but some text information, I try to read the text information out but don't know what VIs I should use. I open the file use text editor it appears something like this:
    È}        A   A      úCš, C²«ŒÂ T)ó>IÉeD  C563 SB5POLY CONTACT .123in. DIAM ENERGY: 1;  DAMPING: 50 TP104 2
     08-09-2005‹ÿýÿçÿÿ±øÿÃíÿNàÿÒÿqÄÿ‡¸ÿ€®ÿ4¦ÿZŸÿ§™ÿÞ”ÿѐÿ[ÿïˆîÙ‡Í{®…úrÚƒ kY‚Âc))]H€"W
    I need to extract only the text information out.

    Just convert it to a byte array. Then, in a loop, check each for e.g. "printable?" or a desired set of "lexical class" (e.g.2,3,4,5) and built a new array from the subset. At the end, convert back to string. (see attached, LabVIEW 7.1).
    (If your string is huge, you should preallocate the array, replace at the current index, then trim it after the loop to the correct size. This optimizes memory allocations).
    Message Edited by altenbach on 10-01-2005 09:27 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    printable.png ‏9 KB
    ExtractPrintable.vi ‏28 KB

  • Problems on saving a binary file

    Hi,
    I have a String object that I need to save on disk, in binary format, for a database implementation project. I am using the FileOutputStream class, like this:
    FileOutputStream fos = new FileOutputStream("file.db");
    byte[] arrayBytes = new byte[myStr.length()];
    arrayBytes = myStr.getBytes();
    fos.write(arrayBytes);
    fos.close();
    The problem is that it saves the string in text (ASCII) format. If I open the file in Notepad it displays all the characters of the string, in a readable format, as it were a .txt file.
    I have some friends implementing the project in Delphi, using a class called "FileWriter". Their file is not readable in Notepad. If we try to open it in notepad, only some characters are readable, other are junk characters.
    As my professor doesn't want the database file to be readable by an ASCII editor, what can I do to save my String in binary format, like "FileWriter" class in Delphi?
    (he said I can't serialize the object to disk)
    The strange thing is that the FileOutputStream class documentation says it writes raw bytes of data. If they are raw bytes, how can I read them in notepad?
    It's confusing to me... Is there any solution for what I need?
    Thanks for your time and help.
    Leo Hyppolito.

    Like I said - search around. Something simple is:public class XOR {
        public static void main (String[] args) {
            String s = "Hello";
            s = flip (s);
            System.out.println (s);
            s = flip (s);
            System.out.println (s);
        private static String flip (String s) {
            String flippedString = "";
            for (int i = 0; i < s.length (); i ++) {
                flippedString += flip (s.charAt (i));
            return flippedString;
        private static char flip (char c) {
            return (char) (c ^ 0x5678);
    }Kind regards,
    Levi

  • Can't read back saved raw PCM file

    I used Audition 1.5 to do a 48kHz 32bit 2 channel recording and then I saved the file as raw PCM and now I can't read it back into Audition. When I enter the values it was recorded with I get an empty recording (but the right length of it). Anyone have an idea?

    jbz2105 wrote:
    Have my past few hours just been a total waste?
    Yep, pretty much unless you know the exact size and can correctly fill out the required dialogs required to open a Photoshop "raw" file. The "raw" format is not, as you've found out related at ALL to Camera Raw. It's really a holder over format from the early years used back when there weren't some file formats available on some computer systems...and yes, you SHOULD have used TIFF.

  • Word 2007 Addin to add Watermark image saved as .doc file

    I currently have an addin that was developed to work in both Word 2007 and Word 2010 with the assumption the addin would be used on .docx files.  However, it is now required to also work on .doc files but still with Word 2007 and Word 2010.  Although
    the following code works in both versions of Word, it will only work on .docx files and not .doc files.  On the line:
    Dim shape As Shape = doc.InlineShapes.AddPicture(strWatermarkFile, linkToFile, saveWithDocument, headerfooterRange).ConvertToShape()
    I get the Error
    HRESULT E_FAIL has been returned from a call to a COM component.
    My code that works in
    2007 on .docx files and not .doc files is:
    Public Shared Function AddWaterMark2007(strWatermarkFile As String)
    Dim app As Application = Globals.ThisAddIn.Application
    Dim doc As Document = Globals.ThisAddIn.Application.ActiveDocument
    Dim headerFooter As HeaderFooter
    Dim hfIndex As WdHeaderFooterIndex = WdHeaderFooterIndex.wdHeaderFooterFirstPage ' WdHeaderFooterIndex.wdHeaderFooterPrimary
    Dim linkToFile As Object = False
    Dim saveWithDocument As Object = True
    If doc.Sections(1).Headers IsNot Nothing Then
    headerFooter = doc.Sections(1).Headers(hfIndex)
    ElseIf doc.Sections(1).Footers IsNot Nothing Then
    headerFooter = doc.Sections(1).Footers(hfIndex)
    Else
    headerFooter = Nothing
    End If
    If headerFooter IsNot Nothing Then
    Dim headerfooterRange As Object = headerFooter.Range
    Dim shape As Shape = doc.InlineShapes.AddPicture(strWatermarkFile, linkToFile, saveWithDocument, headerfooterRange).ConvertToShape()
    shape.LockAspectRatio = Microsoft.Office.Core.MsoTriState.msoTrue
    shape.WrapFormat.AllowOverlap = -1
    shape.RelativeHorizontalPosition = WdRelativeHorizontalPosition.wdRelativeHorizontalPositionMargin
    shape.Left = WdShapePosition.wdShapeCenter
    shape.ScaleHeight(1, Microsoft.Office.Core.MsoTriState.msoTrue)
    shape.RelativeVerticalPosition = WdRelativeVerticalPosition.wdRelativeVerticalPositionMargin
    shape.Top = WdShapePosition.wdShapeCenter
    shape.ScaleWidth(1, Microsoft.Office.Core.MsoTriState.msoTrue)
    shape.Name = "WordPictureWatermark"
    doc.Sections(1).PageSetup.DifferentFirstPageHeaderFooter = True
    End If
    app.ActiveWindow.View.SeekView = WdSeekView.wdSeekMainDocument
    app.ActiveWindow.ActivePane.View.Type = Microsoft.Office.Interop.Word.WdViewType.wdPrintView
    End Function
    Thanks in advance for any suggestions!

    Hi Voyagr,
    I also could reproduce this issue too.
    Since the issue is complex, I'm trying to involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated.
    Sorry for any inconvenience and have a nice day!
    Regards & Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Can jpdk portlets deliver images and other binary files?

    From my understanding, portlets can only return text content (html).
    Images and pdf files would be impossible to deliver via portlets.
    So if you portlet has a link to a pdf or a image, this URL would be a direct reference to that application or file resource, and not be tunnelled through portal?

    Q. From my understanding, portlets can only return text content (html).
    A. Portlets can return html or mobile content
    Images and pdf files would be impossible to deliver via portlets.
    Q. So if you portlet has a link to a pdf or a image, this URL would be a direct reference to that application or file resource, and not be tunnelled through portal?
    A correct
    You may wish to look at the lotto sample which renders gif's

  • Everytime I try to download It says I am saving a Binary File. Then it goes to a blank white page that says downloads at top od page says trying to download and underneath it says canceled.. It shows it is downloading. But can't find it.

    I just seen where it says Windows 32 is not a valid Application. How do I fix that? Will not let me install anything either.

    Hi Barbara,
    I had a similar problem recently and using the "more like this" feature I discovered an answer. To a problem posed by Holo7,  who like myself was a newbie on this platform,  b noir proposed a solution to Holo7's problem that also worked with my problem. It involves downloading a version of MS Windows Instal Cleanup and using it to completely remove all traces of the old version.
    If you look at my problem (follow OldGit66) and the link to Holo7's problem then you will find b noir's answer which I think may help you. I am new around here so you might want to wait for one of the higher status correspondents.
    Regards
    John

Maybe you are looking for

  • Animated .gif as background of spryTabbedPanels tab selected

    So I am creating a website and want to use an animated .gif as the background of the tabs (make it look like the one you have selected is "smoking") however, whenever I try to use an animated .gif as the background-image of the .TabbedPanelsTabSelect

  • Design approach help : BIC Mapping Tool Conversion

    Hi All, Design approach: we know that BIC mapping tool can be used for EDI to XML conversion. also i know that its a Any to any converter. But we prefer EDI to EDI XML conversion only via this tool and do the mapping in SAP PI as it would be easy to

  • Msi Kt333 woes with barton 2500

    Hi, I just got this new processor, the barton 2500 and my computer is very instable. I have a Kt333 ultra 2 with bios 5.7 and it worked fine with an athlon xp1800+ I set up fsb 166 and everything else in auto and It will crash at random in winxp. The

  • How can I license Lightroom 3?

    I have the Lightroom 3 trial version on my PC, and it worked fine. I want to license it and get a serial number for it. My Vista Home Premium 32 bit system will not use the newer version of Lightroom. So how do I get a license for the Lightroom 3?

  • Download lastest version on Install OSX Mountain Lion

    I tried to re-download the latest version of OSX Mountain Lion installer from the App Store, but it says it cannot, because Mountain Lion is not compatible with my computer. I have a new iMac 27" that is running Mountain Lion on a Fusion Drive.  Why