03-15-2016 02:26 PM
Hello everyone,
First of all, im new to labview. Now, this question may have been asked before but im not entirely sure. Ok, so i have an avi video that can be broken down to 50 frames. I used imaq threshold and a for loop to put a threshold in every frame making them black and white. What i want to do is calculate the percentage of area that is highlightened as white. I figured i can do that by calculating the total number of pixels that have an intensity of 1. I know that the black pixels have 0 intensity and i also know the total number of pixels in each frame. I tried using the quantify function but i could not get the desired results. Then i tried using imaq light Meter, but again i could not get the exact number of pixels with intensity of 1, only the mean value and the standar deviation of the pixels. I can probably calculate the area that is intense by using these two values (mean,st.dev.) and simple statistics , i think, but i need more detailed results. Is there a way to get the total number of pixels with intensity of 1 in a black and white frame? sorry if this question has been asked before, i could not find any related one. Sorry for my bad english as well. Awaiting your answers.
Thanks a lot.
Solved! Go to Solution.
03-15-2016 03:23 PM
Hello iskourke,
I'm attaching a snippet (a special picture you can drag onto the block diagram and use as code). You will have to wire in the image, and then choose the correct output of "image to array". I have it hooked up to U16 right now but that will be an empty array if your image is not U16.
03-16-2016 07:45 AM
Thanks for the reply but i think it is not working. I keep getting the same number of pixels for each frame. The number of pixels is supposed to decrease as the material degrades. I can actually see the white regions decrease but there is no decrease in the pixels>1 indicator.
03-16-2016 08:51 AM
The problemwith gregoryj's code is that it converts the array of booleans to a number, not a count, The value of that number depends heavily on the position of the Values in the array which are True.
Once you have the array of pixels of the black and white image (all values either 1 or 0), just use Array Sum to get the number of ones.
Lynn
03-16-2016 08:57 AM
Ah thank you Lynn, I feel so silly now thinking that function would give me the number of "true" elements.
03-16-2016 09:48 AM
ok, so i attached lynn's pixel counter to the code, however the pixel sum i get seems really small. So the total number of pixels is 6624000 and of all of them 2515015 should be of intensity >0 (i got the values through vision assistant previously) which is somewhere to 37% of the total pixels. However, the pixel counter gives me really low values (30000) sometimes going even lower to 5000. I have attached my work so far so you can have a look if you want. Sorry for being a bother and thanks for the replies.
03-16-2016 10:17 AM
Can you save for 2014? (File >> Save for previous version...)
If you look through your array, do you really only find the values 0 or 1, nothing else?
03-16-2016 10:30 AM
ahh there must be a problem. Everytime i try to save for 2014 labview crashes. To answer your question gregory, yes i saw the array and it was full of 0s and 1s only. Anyways, i figured that if i can track the mean value of intensity from one frame to another, then multiply this mean times 100, i can get the area for each frame.
03-16-2016 10:32 AM - edited 03-16-2016 10:34 AM
Are you storing the sum as type U16? The max will be something like 65535 and then it will roll back over to zero.
Try converting to U32 before taking the sum.
03-16-2016 11:07 AM
ok, will do