Binary threshold - U16 Image

I have a simple example which I have attached (Vision 2013 but can save for previous if need be) in which I would like to apply binary thresholding to a range of values (minimum --> mean) in a U16 image.  This example is based on the particle analysis binary threshold example included with Vision for U8 images.  The thresholding does not appear to be working properly (to hilte the range of values red) and areas outside of the range appear to be getting thresholded as well.  Ultimately, what I would like to be able to do is actually display the gray scale (rather than binary) image and have the thresholded range show in red against the gray scale image.
Any thoughts.
Solved!
Go to Solution.
Attachments:
U16 Threshold Example.llb ‏4 KB

Bruce -
Thanks for taking the time to reply.  The first question that needs to be answered is if the binary thresholding VI is properly working to hilite in red the range of values I have specified (non-zero min --> mean) for a U16 image.  The U8 version of this example VI works just fine.  I wanted someone to run my VI and see that what is getting hilited does not seem to match up with the non-zero min --> mean range.
In terms of thresholding on top of an actual gray scale image, another idea is to just find the pixels that fall within the range I have specified, and draw an overlay of points on top of the image.  That should work fine.  However, this is mainly for visualization purposes.
I really need the thresholding itself to work properly for 16-bit images in order to do a particle analysis.  So I needed a sanity check to see if somehow I am doing something wrong in the thresholding (this is a pretty simple VI, not sure what could be going wrong, so am wondering if it is not properly operating on U16 data).
Sincerely,
Don

Similar Messages

  • Thresholding an image in order to determine areas

    Hey everyone,
    I'm somewhat new to Labview and I've only recently gotten the Vision Development Module and the Vision Acquisition software. It's extremely new to me and I'm at a loss. I searched around and couldn't seem to find exactly what I'm looking for, or maybe I didn't understand it enough to know. I'm really just looking for something to get me started.
    I am wanting to create a VI that thresholds an image that is inputed from a previous VI that I have already created in order to determine the area (number of pixels) the objects take up on the picture.  The picture will have several metal objects on top of a colored background and will be later compared to another similar image.
    What would be the best way to threshold this? Based on the colored background (most likely blue or green)? What I picture is for this to turn the image into black and white and then count the white pixels and group them by each object.
    Attached are the image capturing VI which uses a webcam to take a picture and a test VI to try to figure out what thresholding is about.
    Thanks in advance for the help.
    Attachments:
    ImageCaptureVI.vi ‏61 KB
    TestThesholdingVI.vi ‏22 KB

    Hello,
    if you background is for blue for example, you could extract the opposite (complementary) color plane i.e. red to reinforce the contrast before thresholding:
    BEFORE:
    AFTER:
    You can then manually or auto threshold. Manual threshoding needs to know the threshold values. The below part in your code is (probably) not correct:
    Thresholding the image will convert the image to binary, no matter what value you specify, but the output is greatly dependant on this. The equation for Labview threshold function is (check the documentation to be sure):
    IF f(u,v) >= Tlow AND f(u,v) <= Thigh, then f(u,v) = 1, otherwise f(u,v) = 0!
    where f(u,v) is the value of the pixel at (u,v) location and Tlow is the lower threshold, Thigh is the upper threshold.
    The range specifies this two threshold values. After you threshold the image, you can use morphology operations to reduce noisy data, fill holes etc... and use for example particle analysis (on binary image). If you use count and measure objects, you do not need to threshold the image before, since the function does this for you, again by specifying the threshold value(s).
    Hope this helps.
    Best regards,
    K
    https://decibel.ni.com/content/blogs/kl3m3n
    "Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."

  • Problem with loading Binary Stream as image

    Hi all,
    I'm facing problem of loading Binary Stream as image.
    from source system we are getting image in XML file as string (i.e binary stream).
    Now i want to load that string again into table as BLOB. i am able to load in to BLOB column but not able to view image properly. it's giving error like "Image has not been decoded properly from binary stream".
    How can i solve this issues?
    Any help.
    thanks in advance.
    Vinay

    michali7x4s1 wrote:
    Thats a code i found somewhere, tried to check how some things work.Have you used exceptions before? If not, please read the sun tutorial on them as they are very very important. Also, whether this is your code or someone else's doesn't matter as it's yours now, and you would be best served by never throwing out exceptions as is done in this code. It's like driving with a blindfold on and then wondering why you struck the tree. It's always best to go through the tutorials to understand code before using it. If it were my project, I'd do it in Swing, not AWT. Fortunately Sun has a great tutorial on how to code in Swing, and I suggest you head there as well. Best of luck.

  • Imaq mask on U16 image

    Hello!
    Can someone please explain to me the following:
    I can use IMAQ  mask on every image type except for the U16. Why is that?
    Please see the trivial example below.
    I am using Labview 8.6 professional.
    Thank you and best regards!
    K
    https://decibel.ni.com/content/blogs/kl3m3n
    "Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."

    Your Vision Development Module seems to be too old. Support for U16 was covered partially in early versions. Try version 2010 or latest Vision 2011 - for me IMAQ Mask works with U16 image. Both VDM 2010 and 2011 are compatible with LabVIEW 8.6.
    Andrey.

  • How do I set the LUT binary thresholds?

    In a LabVIEW vi I am controlling the acquisition of an image with the IMAQ Property Node. I can select the LUT through the image parameters to Binary or Inverse Binary. However, I can't find the parameters to set the thresholds for binary conversion, both high and low.
    How do I set these?

    I was trying to emulate the properties available in Measurement & Automation Explorer for the camera. Binary is listed as a LUT with controls to set the threshold leves. If I select the Binary LUT through software, the display is black, and if I select Inverse Binary the display is all white. Therefore it must be using an LUT to determine the values. I can't find anything in the property node to set these values however.
    Using IMAQ Threshold will work, but I was assuming using a LUT is different and possibly a speed advantage? Since the LUT is applied before snapping the image, would it not be faster than processing the image later?
    Excuse my ignorance on how the low level IMAQ works.

  • Sample code converting binary data to image file

    Hi experts ,
    I need sample code to convert binary data (bytes) in to an image file.
    any help will be appreciated.
    Thanks and Regards,
    Naresh

    You need to show binary and decimal?  Or now just decimal?
    If binary and decimal, you can right click on your indicator and choose "Display Format...".  If you select the Advanced Editing Mode, you can make soft interesting display formats.  This includes showing the same value in mulitple ways in the indicator.  Try something like "%032b - %d" for the format string.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Convert binary data (TIFF image) into XML - how ?

    Hi,
    I have the following requirement:
    1. A document is scanned and a TIFF image is saved in a directory
    2. The File adapter picks up the image file and sends into XI
    3. The binary data is converted into XML so a Web Service can be called (this web service will store the image in a database application)
    <b>The part I am struggling with is the convert of the incoming binary data into a XML format document which will allow the Web Service to be called.</b>
    Graphical mapping cannot be used therefore I am left with 3 options:
    1. XSLT mapping
    2. Java mapping
    3. ABAP mapping
    Can anyone suggest the best option to use in these circumstances and provide some sample snippet of code on how to do it.
    I am alright at XSLT mapping but this is beyond me and Java mapping is completely new to me as I have very limited Java knowledge.
    Thanks for your help
    Colin.

    Hi Colin
    Look for the below link
    https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/10dd67dd-a42b-2a10-2785-91c40ee56c0b
    <b>***Reward point if helpfull</b>
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/10dd67dd-a42b-2a10-2785-91c40ee56c0b">https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/10dd67dd-a42b-2a10-2785-91c40ee56c0b</a>

  • Least (computationally) burdensome method of adding a filled rectangle to a thresholded IMAQ image

    I regret bothering this forum with such a simple question. I am not very proficient in LabView, so every little design consideration takes a very long time for me to solve.
    I am trying to add a filled black rectangle that covers the top quarter of a thresholded image.
    The initial source are grayscale, 8bit images at ~30fps, that are thresholded into black/white. The resulting thresholded image serves as input for an old imaq vi called "IMAQ Basic Particle" (or in other versions of this routine, "IMAQ ComplexParticle"). I'd like to take this 640x480 pixel, 8bit black and white threshold, and just add a solid black rectangle to the top of it before it goes through IMAQ Basic Particle.
    Browsing the forum (before posting!) gave me some ideas:
    draw rect.vi -> picture to pixmap.vi -> unflatten pixmap.vi -> imaq array to image.vi -> then somehow merge this imaq image on top of the initial? (not sure yet which block to use here).
    draw rect.vi ->...-> imaq overlay bitmap.vi.
    or better yet:
    imaq overlay rectangle.vi  -> imaq merge overlay.vi.
    I've spent the most time with the last route, and have one final problem with it. imaq merge overlay.vi seems to output into 32bit rgb, which my particle analysis blocks do not like. The image fed into, and resulting from, the merge overlay.vi is a simple black and white picture so i assume some final conversion of the 32bit rgb image output from Merge Overlay.vi into 8bit will fix this last problem.
    When searching this topic on the forum, I found a thread where someone claimed that merging images was slowing down their routine significantly. So i came to ask: is this a slow process? is there a better way to do this? The overall program is big, and the speed of operation is my principle concern.

    There's a function for that...
    IMAQ Draw in the pixel manipulation palette.
    Regards

  • Threshold image to D array

    Hello
    I have included 2 Visa. The first one called 'scale image' introduces a picture and converts it to a resolution on 100x100. Is there a way I can export this picture into the second VI which includes IMAQ to threshold the image. 
    I didn't create the second VI it is an example. But from what I Understand it produces the picture into binary. Is there a way I could produce an array with this information on it where the blacks are 1 and the white 0 or visa versa.
    Thanks Craig
    Attachments:
    ScaleImageExample.vi ‏12 KB
    binary.vi ‏43 KB

    Hello Craig
    I am the applications engineer who will be supporting you with this question, as I understand you are looking for alternative methods for displaying image data once you have used the threshold function. Thank you for your thread and including your vi's, this allowed me to look at your code and come up with some ideas without asking you a number of tedious questions.
    Firstly yes you can display your image as an array of binary data, either LED's or 0and1's I have created a project for you which includes your vi's and some additional examples, the additional examples show the new method which you will want to implement.
    Secondly, I created a project so that you can easily pass data between vi's using shared variables, I have created one just to show you, to use the variable just select and drag from the project to your block diagram.
    If you have any further questions or would like any additional examples regarding the conversion of images please get in touch and I will be happy to help. The attached files are in LabVIEW 2010 so if you cannot open them I can down convert them for you.
    Thank you
    Stephanie L
    Applications Engineer
    National Instruments UK and Ireland
    Attachments:
    CraigForum.zip ‏96 KB

  • Threshold image inside loop

    I am trying to threshold an image inside a while loop so the user can fine tune their threshold values.  The threshold values are being iterated correctly but when the image passes through its 2nd iteration the image goes black or disappears.  Any suggestions?  Thanks.
    Alex

    ladouceuraj a écrit :
    We are currently using shift registers but its not working.  The value is changed correctly but the image does not change.  In fact the image either completely disappears or it is thresholded entirely black.  I have attached a ss of the loop.
    According to the diagram, this behaviour is normal : once the image has been thresholded, the original data are replaced with the new [0, 1] values. Nothing left for another run.
    Define a second image and wire it to the "destination image" input of the threshold function.
    BTW, a shift register is completely useless when working with images, since the wire contains a reference  to the image structure, not the data itself.
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • Where to locate and how to use the filter thershould to binarized image

    Good morning friends. I am using
    Labview with VDM and let me know where to locate and how to use the
    filter thershould. Also that parameters used to binarized image captured
    via webcam and display it in black and white.
    Thank you very
    much.

    Is the image that you are getting a RGB one? Use color plane extraction and then use a binary threshold to convert it into a binary image. You can also directly use a color threshold and convert a rgb (color) image to a binary image.

  • Image type problem

    Dear all,
    I've modified the threshold example for a single U16 image of cells, which, while running and changing the threshold values, shows the original example, the thresholded example, as well as to histographs for both images.
    However, somewhere, something goes wrong with the image type and the thresholded image never shows the way it should. I have been working on this for days, but I still can't find the problem. Can anyone tell me what I am doing wrong?
    Thanks in advance.
    J
    Attachments:
    SubVI5 v1.vi ‏98 KB

    The problem is that the thresholded image is completely white, with only two very small blots of black. Also, the image doesn't change upon changing the threshold value. Finally, the histogram shows weird values.
    I expect it must have something to do with the image types used throughout the VI..
    Attachments:
    subVI 5 image.JPG ‏110 KB

  • Assigning a palette to create an image file

    I am using IMAQ Vision for Measurement studio in Visual Basic and need to output an image with a specific palette. Whatever I have tried has resulted in a default grayscale palette being used for the output. Note, my input image has been thresholded to a binary, but this problem also occurs with a full range of values in the image. Most of the time the grayscale work but I really need color for this output!
    Here are the steps I am using
    'Threshold Image
    CWIMAQVision1.Threshold CWIMAQViewer1.Image, CWIMAQViewer1.Image, 1, 255, True, 1
    ‘On screen I now have a red 1 and black zero values when using the Binary Palette, that is how I would like the output to be!
    'OUTPUT JPG
    'Output Image
    OutName = App.Path & "/" & App.EXEName & "Test" & ".jpg"
    CWIMAQViewer1.Palette = cwimaqPaletteBinary
    CWIMAQVision1.WriteImage CWIMAQViewer1.Image, OutName, cwimaqFileJPEG, CWIMAQViewer1.Palette
    The image I get is Black! If I threshold to 254, I get Periwinkle as the color, (127, 127, 255) on screen and white for the same values in the output image. I am new to IMAQ Vision for Measurement studio in Visual Basic and may just be missing something in the syntax, the help files don’t help explain this except grayscale is the default! How do I override this?
    Secondly is there a way to take the current image from CWIMAQVision1 and place it in a VB Picture box? Similar to Picture1.Picture = Picture2.Image in VB takes the current image and transfers it to another picture box?

    The reason that you always see white instead of red when try to view your image outside of the cwimaqviewer is because the binary image is saved as an 8-bit image (thus no color). Look at this application I put together where I added two more color planes to the images to get a full fledged RGB image.
    Happy Programming....
    Attachments:
    Binary_Image_Save_in_VB.zip ‏4 KB

  • How can I automate the threshold for a moving object whose light intensity changes for each frame.

    I'm using the PCI-1408 and I have this video where an object's shape and color intensity changes for each frame. I want to do a pixel count of that object verses the background (the background also changes color) for each frame. I'm guessing that I need an automatic threshold, but I really have no idea of how to implement this. Any ideas, anyone?

    Hopefully there is a clear distinction between the background and the object.
    You can use IMAQ AutoBThreshold to determine the threshold level for an image. You can select from a variety of methods for determining a binary threshold level. Route the "Threshold Data" output along with your image to IMAQ MultiThreshold, which will quickly apply the threshold to your image. Display the results using WindDraw and the Binary palette (from IMAQ GetPalette).
    This should run close to real-time. Binary thresholding is a fairly fast operation. You will probably end up processing every other image, which is close enough for most projects.
    Bruce
    Bruce Ammons
    Ammons Engineering

  • Looking for some advice regarding an image related program

    Hi fellas, Im looking for some guidance here. I want to write a program that will read an image (image will be an xray image of a square), convert the image to black and white, and measure the length and width of the square. Im looking for the best progamming langauge to make this happen. Anyone have any recommendations? I know c++ has a good imaging library that would be helpful so im looking into that at the moment. And Im pretty sure I can do this with matlab, but Im writing this program for a doctor so I need it to be portable. Thanks in advance for all the help
    Cliffnotes:
    Whats the best programming language to:
    -read an image (of a square)
    -convert image to black and white
    -measure length/width of square
    -GUI would be good but not necessary
    -easy to write

    HashBox wrote:You might want to look in to DPI and what The GIMP does in terms of that, also I found this which might be of use as well: http://en.wikipedia.org/wiki/Pixels_per_inch
    Thanks HashBox, I think Im off to a good start on this. First, I wrote the program (majority of it) using matlab, and now Im trying to convert it to C++. So far I have:
    #include <stdio.h>
    #include "CImg.h"
    using namespace cimg_library;
    //main program
    int main()
    CImg<double> img("xray.jpg");
    //converts the image to black and white
    img.RGBtoYCbCr().channel(0).resize(-100,-100,1,3).RGBtoLUT(CImg<>(2,1,1,3).fill(0.0f,255.0f),false);
    //displays image
    CImgDisplay display(img,"Black and White");
    while (!display.is_closed)
    display.wait();
    return 0;
    So right now, I have the black and white xray image. How do I find out the size of the image using c++? Is there a function for that or do I have to write code to find it manually?
    Heres the original matlab code I wrote that Im trying to write my c++ code after:
    %read the image
    [filename,pathname] = uigetfile('*.*', 'Select an image');
    %assign image to film
    film=imread(filename);
    %threshold the image
    level = graythresh(film);
    %convert image to black&white using the thresholded value
    BW = im2bw(film, level);
    %display image
    imshow(BW);
    SIZE=size(BW);
    counter=zeros(1, SIZE(1));
    for x=1:SIZE(1)
    for y=1:SIZE(2)
    if (BW(x,y)==1)
    counter(1,x)=counter(1,x)+1;
    end
    end
    end
    SUM=0;
    lines=0;
    for counterarray=1:SIZE(1)
    if counter(1,counterarray)>0
    lines=lines+1;
    SUM=counter(1,counterarray)+SUM;
    end
    end
    Last edited by wankel (2009-04-24 21:15:46)

Maybe you are looking for