From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to subtract two continuous images and save them?

Solved!
Go to solution

I am using Labview2010.

On a front panel, I'd like to display one live screen of a camera, two continuous  images taken by the camera, and their subtraction . I also want to save those three images.

The meaning of 'continuous images' that I'm mentioning here is to take the second  image as soon as the first image has taken after I press a trigger button.  

I attached my program below. In my program, I am struggling with the type of wiring.

Even though I could take two images as 1D array (type definition: IMAQ Image.ctl), I don't know how to save them as image files and also how to subtract them. I tried to use the operator of subtraction, but in order to use it , I have to change type definition from "IMAQ Image.ctl" to "Unsigned byte integer 8bit". I first change 1D array to Character array, then change those character array to Unsigned byte array(1D). Then change Unsigned byte array of 1D to 2D.

However, my program does not work properly...

 

Please help me.

0 Kudos
Message 1 of 6
(4,036 Views)

You've already found "ImageToArray", which will give you the pixel intensities. With these you can do additions like add or subtract. To get that back into an image, you can use the opposite function "ArrayToImage", and use the save image VI to save it to a file.

 

(So get rid of anything that creates arrays of the purple image wires, and anything that converts to strings)

0 Kudos
Message 2 of 6
(3,994 Views)

Thank you for your reply.

I tried to apply your advice, but there are still errors. 

As you can see in my error containing program below, there are terminal errors. How can I solve this?

(I read this site but does not work properly.

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000kEYnSAM&l=ja-JP)

 

In addition,  there is an error saying "This type mismatch may be caused by an older instance of the Image data type. To fix it , simply replace the instance with the IMAQ Image.ctl type definition in the Image Controls menu palette."  so I rewrote all the program from the scratch, but the same error popped up again. I don't know why this happens.

 

Help me please.

0 Kudos
Message 3 of 6
(3,978 Views)
Solution
Accepted by topic author mk316

Hi mk316,

 

We just call those "broken wires". The reason they are broken, is because you have an array of images, but the "image to array" function wants a single image. So get a single image either using "index array" or by not creating an array in the first place. 

 

By the way, I noticed you take the U8 output from one of the image to array functions, and the I16 from the other. Only one of the outputs will actually have data in it, depending on what type of data is in your image.

Message 4 of 6
(3,966 Views)

Sorry for my late reply.

I  changed from I16 to U8, and correct other functions, then my program worked well!

 

Thank you a lot!!

 

0 Kudos
Message 5 of 6
(3,919 Views)

Yes, they are certainly odd functions. Most other LabVIEW functions that could have multiple types of output would be a polymorphic function, then you would select which instance you need from a drop-down. I think the image functions are different because they were developed by someone else, and then NI bought them. (just something that I heard a while ago)

0 Kudos
Message 6 of 6
(3,907 Views)