Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

vision software THRESHOLD

I want ot replicate the Greyscale>Threshold function in the NI Vision Asistant 8.5 on a greyscale image. I am developing a .Net standalone application. I would appreciate any help.
Majid
0 Kudos
Message 1 of 16
(6,214 Views)
Hi Majid,
The Threshold operation is a fairly standard image processing step - if the image is converted to a 2D array, the user would then specify a minimum grayscale value and/or maximum which to keep, and all values outside of that specified range would then be replaced with whichever new value you specify (usually 0 or 255 if using 8-bit grayscale).

See the VI help in Start » Programs » National Instruments » Vision » Documentation » NI Vision, and in there take a look at Image Processing VIs » Processing VIs » Threshold to get a better idea of how the inputs and outputs to that VI work. However, you will not be able to convert the 2D array back into an IMAQ Image type without also distributing a Vision Run-Time engine, which also requires a Vision Run-Time Engine license.
Message 2 of 16
(6,199 Views)

Vijay,

Thanks for you reply. Using regular threshold operation is very straight forward. Let me explain what I want to achieve:

I am working with grayscale images and I want to apply threshold where the resulting image will show the original image in the background and the pixels passing the threshold will appear in color, superimposed on the original grayscale image.

I have tried to with CWIMAQViewer with Binary palette where the pixels passing the threshold shows up in color, but I was unable to show the original grayscale image in the background.

I want to achieve the same effect as “NI Vision Assistant 8.5” functionality, Greyscale>>Threshold on an image. How I do this?

We have NI Vision dev module with additional run-time licenses so I am worried about deployment.

 

Ekramul

Message 3 of 16
(6,164 Views)
HI ekramulk,

I'm sorry, I misunderstood what you were trying to do earlier. I came up with a complicated way to accomplish this earlier, but now I've found a better way and will share it here with you. In a step by step outline that can be done in LabVIEW or text-based languages:

1. Create two new image buffers, one for an "replacement mask" and one for your "final output"
2. Run your 8-bit grayscale source image through your IMAQ Threshold step, and use the "replacement mask" image as the destination
3. Recast the grayscale source image into an RGB32 data type, using your "final output" image buffer for the destination. This will be the image we'll overlay our thresholded color onto
4. Use an IMAQ Fill Image step with the RGB32 image "final output" as your source, the desired replacement color (in the Vision Assistant case, Red = 0xFF0000) for your pixel value, and the output of the IMAQ Threshold step (the replacement_mask image) as the Image Mask input

This will change all the pixels which meet your thresholded range to the color you specified in the Fill Image step. I've recreated this in a LabVIEW block diagram screenshot (attached)
0 Kudos
Message 4 of 16
(6,151 Views)

Thanks, it worked.

I have another question:

I have a bunch of .tif interlaced images. When is load them onto a zoomed in CWIMAQViewer (zoomed at -1), only the even or odd frames are displayed, however, in the normal viewer (zoom level =1), I get both even and odd frames. How do I display both the even adn odd fields in the viewer? I know I can trap the zoom event and post process the image before displaying on the viewer is an option. Do I have any other option?

Ekramul  Majid

 

0 Kudos
Message 5 of 16
(6,070 Views)
Dear Majid,

Do you get the same behavior at all the negative magnification factors (-1 through -4)?
Do you see normal behavior when setting the magnification factor to any positive value (1 through 4)?
What happens when the zoom factor is 0?

I'm interested to see how the behavior differs with the different zoom factor settings. Also, have you tried setting the CWIMAQViewer.ImmediateUpdates property to false as mentioned in this KnowledgeBase article?

How Can I Remove the Flicker in the CWIMAQViewer Display?
http://digital.ni.com/public.nsf/allkb/403C398499DC2C0086256C17005238D7?OpenDocument


Best Regards,

Nate
Message 6 of 16
(6,034 Views)
Hi Holmes,
I have confirmed the behavior:
For zoom scale -1 to -4, only one of the frames (even or odd interlaced tiff) are displayed. For Zoom scale 0 or positive values, the image viewer displays the normal image, that is, the even and odd images are superimposed(?).
 
I did not have any flicker, and setting CWIMAQViewer.ImmediateUpdate to true or false had no effect.
 
Thanks,
Ekramul Majid 
0 Kudos
Message 7 of 16
(6,022 Views)
Hi emajid,
  • When you see only the odd frame or only the even frame, are you seeing the a full-size image where the displayed lines separated by blank (or black) space, or are you seeing a half-height image that only consists of odd lines (or only consists of even lines)
  • If you rescale the image up or down before displaying it, do you still see this behavior?
  • What about if you use CWIMAQVision.InterlaceSeparate to separate the frames and then recombine them using CWIMAQVision.InterlaceCombine?
0 Kudos
Message 8 of 16
(5,993 Views)

Hi Vijay,

Thanks Vijay for your reply.
- When I see the odd(even) frame, I am seeing full size image, Looks like the odd(even) fields are re-combined with even/even or odd/odd fields(?), because in the original image in full scale the odd(even) fields are visible.
- On rescale, zoom level 0 to 4 the image is displayed correctly.
- InterlaceSeperate and Interlacerecombine does not fix the problem.  

 

Thanks,

Ekramul

0 Kudos
Message 9 of 16
(5,923 Views)
Hi ekramul,
Do you have a small test image you can attach which demonstrates this behavior? I'd like to try and reproduce the error, but I don't have a suitable source image. To my knowledge, IMAQ does not currently support multi-page TIFF files, but I don't know to what extent TIFF interlacing is supported. Since the format is so flexible and can include so many different tags, it's difficult to include reliable support for so many features.
0 Kudos
Message 10 of 16
(5,883 Views)