LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

count the number of pixels of a specific colour in an image

Solved!
Go to solution

Hello,

I want to read a set of PNG images after eachother. The no. of blue pixles should be counted in each image and compared to the first image.
My first question; what is the best way to read a large number of images automatically after eachother?
My second question; is is possible to read the color intensities of an image in a form of a 1D array, specify the intensity range, for example for blue color, and search the array for those values, then calculate the % of values that belong to this range? Is it also possible to count the pixels that belong to this range?

would be very thankful for your help!

0 Kudos
Message 1 of 9
(4,061 Views)

Hi Sarah,

 

what is the best way to read a large number of images automatically after eachother?

I would suggest a loop…

 

is is possible to read the color intensities of an image

Yes.

Browse the picture functions palette for inspiration…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(4,054 Views)

what is the best way to read a large number of images automatically after eachother?

I would suggest a loop…

yes:) I can pass an array of input files in a loop. But I cannot read files from a folder after eachother (something like 10000 files). I don't know how to do to this.

 

is is possible to read the color intensities of an image

Yes.

Browse the picture functions palette for inspiration…

thank you for the hint! my full question relates to the subject of the message.. I can read the images and unbundle the image data and output a 1D array of numbers refering to rgb values. I don't know how to count the pixels that relate to the intensities. Is it enough to search this array for an intensity range, calculate the % of values found inside this range and then take this % value as a reference for the no. of colored pixles? I don't know if the this is correct.

 

 

 

0 Kudos
Message 3 of 9
(4,039 Views)

Hi Sarah,

 

I can pass an array of input files in a loop. But I cannot read files from a folder after eachother (something like 10000 files).

So you know how to pass an array of filenames to a loop, but you don't know how to read a picture file? Really?

(Btw. folders with 10k files inside are tend to be slow on Windows. I would avoid such folders…)

 

output a 1D array of numbers refering to rgb values. I don't know how to count the pixels that relate to the intensities.

So you get an array of RGB values, but you can't count intensities?

RGB values are just intensities of R, G, and B component of a pixel color!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 9
(4,032 Views)
Solution
Accepted by topic author s.steen

You mean all 10000 images need to be there in memory?

-If not read the image and then dispose it.

-To read the images continuously, use List Folder and get the file names index with loop and build path inside loop and read image.

-Check IMAQ Color Histogram for the Pixel Intensities.

 

Thanks
uday
Message 5 of 9
(4,023 Views)

I know how to read an array of files by giving in their paths manually . I know how to read a picture file.
I know how to read a folder.

I don't know how to open all the files in the folder after eachother (means, how to create an array of the  input files inside this folder).


@GerdW wrote:

(Btw. folders with 10k files inside are tend to be slow on Windows. I would avoid such folders…)

 

what do u suggest?


0 Kudos
Message 6 of 9
(4,020 Views)

Thank you udka ! I will try this...

0 Kudos
Message 7 of 9
(4,017 Views)

Hi Sarah,

 

how to create an array of the  input files inside this folder

Ever heard of the autoindexing feature of LabVIEW loops?

They make it very easy to create arrays…

 

Are you sure you want to have 10k+ 2D arrays into a single 3D array? What's the size of your images?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 9
(4,012 Views)

thank you for your answers GerdW.. I think I couldn't formulate my questions correctly so that you understand what I mean..but no problem, I've got the solution to the most part of my problem through the short answer of udka. I will keep only the first image in memory, read the next image file, compare it to the first and give the no. of pixels and then dispose it, then take the next file, ..and so on. I should not open all of the files in the folder in the path array, but rather open one, delete, open the next, and so on. The imaq histogram is good enough for the other issue i think. I'm trying it..

0 Kudos
Message 9 of 9
(4,007 Views)