Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

why I can't subtract two images in imaq vision builder?

Hi,
I have many times tried but failed to get the objects in a image by subtraction with another image which is background, in imaq vision builder(ver. 6.0). I totally can't use the "operators" command under "greyscale" to subtract the two images becauee all commands under the "greyscale" are always unactivated after two images have been stored in 2 idfferent buffers. I really don't know why and this vision builder is so difficult to use, unbelievable! I followed the instructions in its Help and it's quite simple but I totally failed to make this operation!

Two samples of images have been attached and maybe it's very ease for you to filter out objects(fibers) by subtraction each other. Show me your scrip
t if you can. It's urgent to me.

Or the idea of the way I thought for filtering the objects is wrong? Point out please if you know.

Thanks and Merry Christmas and Happy New year!!

Swedlin
Download All
0 Kudos
Message 1 of 10
(4,731 Views)
From my viewpoint, this is one of the disadvantages of the Vision Builder software. When you use a script, you can't use reference images and subtract them, etc. Vision Builder really only works with single image analysis. Anything with multiple images, like comparisons, doesn't work well.

This is really easy to do from LabVIEW, though. Just load your reference image and subtract it from each new image.

Bruce
Bruce Ammons
Ammons Engineering
0 Kudos
Message 2 of 10
(4,731 Views)
Okay, this is not quite as straightforward as it could be, but you can do image subtraction in Vision Builder. The basic idea is as follows:

- select first object image and copy it to buffer 1

- select "image >> get new image" and load your background image from a file.

- put this in buffer 2

- retrieve object image from buffer 1

- perform subtraction. Even though these images appear to be greyscale, they are actually saved as 24-bit RGB images, so you need to use the color operators instead. Vision Builder will only allow you to select steps that are valid for the image you have loaded. You could extract the luminance plane from all of your images to work with 8-bit images if you like.

I have attached below a background image, several object i
mages, my script, and the results of batch processing. You will need to edit the "get new image" step with the correct path to the background image on your machine.

Bruce is right though. This is a bit easier in LabVIEW.

Regards,

Brent R.
Applications Engineer
National Instruments
0 Kudos
Message 3 of 10
(4,731 Views)
Oops. Here's the attachment.

-Brent
0 Kudos
Message 4 of 10
(4,731 Views)
Thank you very much, Brent

I am very pleasure to see your results. I had got the same results as yours last night though I was not fully understand all steps but now better. I didn't use COLOR OPERATORS. I used EXTRACT COLOR PLANES under COLOR. Then GREYSCALE will be activated after that.

I will make some batch processing testing before it can be invoked by other vi.

Happy New year!!!

Swedlin
0 Kudos
Message 5 of 10
(4,731 Views)
Why does subtracting two grayscale images in vision builder has to be that complicated ?
Seems like a rather poor performance from NI ?
Any hope for a change to the better ?
0 Kudos
Message 6 of 10
(4,731 Views)

What do you mean "subtract" it?  Using the little subtraction math triangle thingy?  I guess I'll try that...

0 Kudos
Message 7 of 10
(3,604 Views)

Oops -- wait a minute.  I think I found the image add/subtract/etc. functions in IMAQ Operators.

0 Kudos
Message 8 of 10
(3,603 Views)

I am just trying to subtract 2 8 bit images and keep getting a result of zeros across the resultant pixel array, i.e. black image!  I have been doing image processing in imageJ for years and I am finding LabVIEW to be super tedious.  This should be extremely easy to do.  Why can't I just subtract two images using IMAQ subtract??  Why does NI make this so diffcult?

 


@SteveAtBoeing wrote:

Oops -- wait a minute.  I think I found the image add/subtract/etc. functions in IMAQ Operators.


 

0 Kudos
Message 9 of 10
(3,123 Views)
Can you post your code along with the images, so that we can see what is wrong.
Thanks
uday
0 Kudos
Message 10 of 10
(3,114 Views)