LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

superimposing 2 images

I am trying to create a graphics file superimposing 2 different images. One is a jpeg file that was imported and the other is a picture internally created I connected both of them together, but my output only had the jpeg file and didn't include the internal image. Is there something special you have to do to integrate 2 images?
0 Kudos
Message 1 of 27
(4,997 Views)
Like I said in my answer to your other question, you may wish to look at IMAQ for something like this. Another suggestion, which is also relevant to your other question, is to post your VI if you have a problem with it.

As for your question, you will probably need to write an algorithm for going over the pixel array from one of the pictures and replacing only some of the elements with elements from the other picture (let's say going over the 1D array and replacing every other element, which is probably easiest). I'm not sure how good it would look, but you can try it.

___________________
Try to take over the world!
Message 2 of 27
(4,977 Views)
Since I dont think it would take very long to try it, and you technically need to combine elements from both sets of pixel arrays, I would suggest creating a third image from the two you have by an XOR. If one image is darker than the other you might have to further process it to equalize the two before hand so one doesnt drown the other out.
Message 3 of 27
(4,976 Views)
Thank you so much for your advice. I'm attaching the vi I used to try to superimpose the two images. I used the concatonate vi to combine the two pictures, but where the pixels overlapped in the images it just used one image and the other just showed up outside the border where there was no overlap, regardless of how bright or dark the colors on the images were. Is there a different function other than the concatonate that I could use that would actually combine the images?
0 Kudos
Message 4 of 27
(4,950 Views)
Took it and modified for a down and dirty possible solution. It helps if they use a restricted palette but this isnt always easy to get done. You can change the logic by replacing the XOR with some other boolean expression to see if, for your pictures, its any better...

Hope this helps.
Message 5 of 27
(4,943 Views)
Attached you will find a crude mod of the VI posted by Chaos (in LV 7.1).

In it I break eack of the pixels up into the three color componenets and then average the RGB value of each.

The average of the three components is then combined back into a single pixel.

This example expects jpgs of the same size and is CPU intense.

Trying to help,

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 6 of 27
(4,925 Views)
If you are able to get a per pixel RGB array as in Ben's example (I have 7.0 on my machine so I couldn't view it at the moment) you are not restricted to averaging the values, you can implement an alpha channel (on a per picture or per pixel basis)and make the image have transparency. Basically is graphics objects (in this case images)have each value of the 8-bit RGB weighted by some fraction, Alpha. This will allow you to make uneven blends and add some robustness to overlaying multiple images (especially more than two). You can make your Alpha channel a value from 0.00-1.00 where 0.00 is completely transparent and 1.000 is fully opaque. If a 50:50 blend is fine then just ignore my suggested modification.

-Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 7 of 27
(4,915 Views)
Paul's suggestions is definately an improvement over my method.

Here is a slightly modified version in LV 7.0.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 8 of 27
(4,901 Views)
Another possibility is to use the builting LV Mask feature which create an overlay (no nice color blending like Ben did, but it is faster)

PJM


  


vipm.io | jki.net

Message 9 of 27
(4,894 Views)
Further modified version of Bens... very nice BTW! Well done!

Based off the fact that the colors are stored by bytes [Not Used][Red][Green][Blue] and if you reverse the order of operations, IE do division first then add together for average, for dont have to worry about a possible carry condition.

This simplifies the diagram and speeds up the algorithm considerably...
Message 10 of 27
(4,885 Views)