09-17-2014 01:20 PM
Hi all,
I have a Gige Vision camera(baselar's) I want to continously grab the images (video) and output the Average or median of the frames(10 frames atelast). My camera setting and pixels hieght widht are mono 8 and width and height are 1000. I tried to get the average in simple adding and division but was unsuccesfull in getting the final images can any one check where I can be wrong , attached is my vi.
thanks
09-17-2014 02:36 PM
That's easy. I don't even need to see your code to tell you what you're doing wrong. You are probably storing your data as 8-Bit unsigned, taking ten images and adding them together. The problem is that the largest value U8 can hold is 255, so you run out of space for the numbers to increase.
Grab the U8 image, cast it to a SGL, and convert image to array. Then add the previous array to the current array in a for loop, and divide by the total images. You can either display the image as a SGL, or cast it to some other type for saving to disk, since SGL is not supported in any common image file format.
09-17-2014 02:43 PM - edited 09-17-2014 02:44 PM
@MoviJOHN wrote:
That's easy. I don't even need to see your code to tell you what you're doing wrong. You are probably storing your data as 8-Bit unsigned, taking ten images and adding them together. The problem is that the largest value U8 can hold is 255, so you run out of space for the numbers to increase.
Grab the U8 image, cast it to a SGL, and convert image to array. Then add the previous array to the current array in a for loop, and divide by the total images. You can either display the image as a SGL, or cast it to some other type for saving to disk, since SGL is not supported in any common image file format.
Hi MoviJohn,
I tried putting imaq cast after imaqdx get image and giving the output of cast image to image to array, but it didnt work, i dont se the images at all.
09-17-2014 04:39 PM
You missed my point.
>Grab U8 Image>Cast the Image to SLG>Convert Image to Array of SGL>Put this array into the shift register of a FOR LOOP that runs 10 times>Divde the output of the shift register by 10>Convert Array to Image type SGL>Display Image as SGL>Cast Image to U8 if saving to disk
For each cast/image conversion, you should use a separate IMAQ Create Image call, each with a unique name, so things don't get mixed up in the same memory space.
09-18-2014 12:43 AM
Probably this topic will be helpful for you:
My recommendation - do not use IMAQ to Array in this case - you will get performance issues (otherwise I don't know your performance requirements). You should be able all computations on pure IMAQ images without LabVIEW Arrays.
The common idea for running average is to keep array of images in the buffer and on each iteration subtract the oldest from accumulator and add newest, then divide to number.
Running median will need more computer than averaging.
Andrey.
09-18-2014 07:05 AM
@MoviJOHN wrote:
You missed my point.
>Grab U8 Image>Cast the Image to SLG>Convert Image to Array of SGL>Put this array into the shift register of a FOR LOOP that runs 10 times>Divde the output of the shift register by 10>Convert Array to Image type SGL>Display Image as SGL>Cast Image to U8 if saving to disk
For each cast/image conversion, you should use a separate IMAQ Create Image call, each with a unique name, so things don't get mixed up in the same memory space.
Hi MoviJohn, thats what I did in my vi, I am not sure where its wrong. can you point out where I need to change the program.
09-18-2014 07:10 AM
@Andrey_Dmitriev wrote:
Probably this topic will be helpful for you:
My recommendation - do not use IMAQ to Array in this case - you will get performance issues (otherwise I don't know your performance requirements). You should be able all computations on pure IMAQ images without LabVIEW Arrays.
The common idea for running average is to keep array of images in the buffer and on each iteration subtract the oldest from accumulator and add newest, then divide to number.
Running median will need more computer than averaging.
Andrey.
Hi andrey,
thank you, but I have a Gige vision camera and dont have any imaq configuration file , I tried replacing the vi with imaqdx but was not succesfull . I dont see any vi for in imaqdx to configure buffer or list.
can you tell me how to modify that program mentioned the topic you suggested.
thanks
09-18-2014 08:09 AM
09-18-2014 08:17 AM
@MoviJOHN wrote:
Inside the FOR LOOP, WHERE YOU take the array data, you are taking the u8 output instead of the SGL, so the color of your shift register is blue, but should be orange.
Hi MoviJohn,
I am not getting what you are suggesting , I tried to wire it to float but still I am not getting images out.
09-18-2014 10:13 AM
Your shift register in not initialized. This would be like 1+NaN=NaN.
Two choices:
1. Put a First Run? Case that simply passes the first image into the shift register without adding (or check for Loop "i"=0
2. Initialize the array on the outside, and make sure to define the correct size dimensions.