08-20-2013 07:58 AM
Hi all,
I have a case in which I have to perform a subtraction of a live video grab (from a usb camera) from a still image to find the displacement in the object, I am trying to convert everything in grayscale then perform subtraction but I also need to convert that final subtracted video into an array and add a scalar value basically adding 255 or 128 to give better view of the subtracted video. Attached is my vi , please let me know where I am doing wrong.
08-20-2013 02:38 PM
Hello,
at the point where you are adding a 2D constant to the 2D array, you have only the first element Array(0,0) = 255 initialized. All other elements are uninitialized (see the image below):
Could this be your problem? Try:
Best regards,
K
08-21-2013 07:08 AM
@Klemen wrote:
Hello,
at the point where you are adding a 2D constant to the 2D array, you have only the first element Array(0,0) = 255 initialized. All other elements are uninitialized (see the image below):
Could this be your problem? Try:
Best regards,
K
Thanks, Klemen,
I will try that, is there any another way of doing subtraction of a video from an image , i just want to show the displacement or the movement.
-AnkitG
08-21-2013 08:05 AM
Hello,
what do you mean by any other way? I do not understand, could you please explain a bit more about this? The IMAQ subtract is designed for the purpose of subtracting one image from another. Also, you do not need to convert the image to an array to add constant to each pixel intensity. You can just use IMAQ add and wire a constant.
Best regards,
K
08-21-2013 08:21 AM
@Klemen wrote:
Hello,
what do you mean by any other way? I do not understand, could you please explain a bit more about this? The IMAQ subtract is designed for the purpose of subtracting one image from another. Also, you do not need to convert the image to an array to add constant to each pixel intensity. You can just use IMAQ add and wire a constant.
Best regards,
K
Thanks Klemen,
I will try to use IMAQ add, actually here I am trying to subtract an image template from a live video which is an rgb video and doing the subtraction from the still image to check the displacement in the live .
Thanks,
08-21-2013 09:45 AM - edited 08-21-2013 09:46 AM
Hello,
just one more thing - when using IMAQ create, it is always prudent to specify the image type also. This way you can immediatelly determine the image type you are using.
Also, looking at the part of the code below (at first i thought that you are using I16 image to extract the red channel -> i was just about to ask how does this work for you ), you are converting to I16, but not using the output. Next, you are subtracting (or adding) two U8 images with U8 as dst - you can quickly underflow/overflow your datatype (for example 50-80 will result in value of 226).
What exactly is the problem about your application? What does not behave as expected?
Best regards,
K
08-21-2013 10:09 AM
@Klemen wrote:
Hello,
just one more thing - when using IMAQ create, it is always prudent to specify the image type also. This way you can immediatelly determine the image type you are using.
Also, looking at the part of the code below (at first i thought that you are using I16 image to extract the red channel -> i was just about to ask how does this work for you
), you are converting to I16, but not using the output. Next, you are subtracting (or adding) two U8 images with U8 as dst - you can quickly underflow/overflow your datatype (for example 50-80 will result in value of 226).
What exactly is the problem about your application? What does not behave as expected?
Best regards,
K
Hi Klemen,
Thanks,I was using the type cast before but using grayscale I16 was giving me error "image type not supported". My main problem is to give the better scene of displacement and since I am subtracting the live video from the mask(still image), its little diffcult to know which side the displacement happen right or left, up or down, I was using the absolute difference before which also works but couldnt get the desired result or knowing which side the displacment happen. right now it does work but not as perfect as we wanted to.
Ankit