Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How to extract the red layer from BayerRG8 file with VBAI?

Dear readers,

 

We're currentely trying to build a inspection program using a CVS and two cameras.

 

A first question to help us: How can we extract the red layer from a Bayer RG8 image?

To illustrate a lit bit more: lets take a picture of chilis and tomatoes plants. We would like to extract the red color of the picture to know where the vegetable are and if they are eatable.

So, in a first time, we just want to see the red layer of the picture.

 

On a second step, we would like to extract the poistion of the red areas and rank them according to intensities and store all the relevant data in a .txt file.

 

Thank in advance for the time you will spend on that topic.

 

Regards

0 Kudos
Message 1 of 12
(6,361 Views)

Auto-reply.

 

The step for the red has been done. Now we're working on following steps:

- to evaluate intensity of each pixel,

- to store the pixel position with intensity in red.


And we're find new problem, as usual, Smiley Frustrated :

- the intensities function in only available for grayscale picture, why? is there a way to change that?

- for pixel position, should we set up a coordinate system or not? We just want to know the pixel positions and and not to convert in universal system unit ...

 

So, please let us know if you have any clue or idea to help us.

 

Have a nice friday afternoon.

 

Mathieu

 

0 Kudos
Message 2 of 12
(6,353 Views)

Maybe including a picture with the info you want would help. It sounds like you could use a detect object step (which works with color images), and you could get the position of all red objects. I would also recommend using the Hue plane instead of the Red plane to look for color since this is more robust to lighting changes. Once you have the bounding box for each red object, you can create a programmatic ROI around it and use the Measure Color step to get detailed color information about your reb objects. Here's a sample inspection that uses colored candy to give you an example of what I'm suggesting. Let us know if more specifically what you are looking for if this doesn't help. The example is in VBAI 2012. Let us know what version of VBAI you are using because this may affect what functionality you can use.

 

Thanks,

Brad

Message 3 of 12
(6,350 Views)

Hi Brad,

 

Thank for your answer.

 

First to all, we use the VBAI 2013.

 

Thank for your advice about Hue. We will try. We're working on underground structures with very small variation of light.

 

We just used the object extraction (see enclosed file) and it's working well. Thank.

How to define the bounding boxes as ROI? Can we just record an empty image with the identified ROI? if yes, how?

I will have a look on your file.

 

Now, we're stopped because we would like to record processed image on a USB stick link to the CVS. We plugged the USB Stick, and VBAI said us to build global channel with DAQmx ... to be honest, we just don't understand that.

 

Brad, thank for your useful help.

 

Mathieu

0 Kudos
Message 4 of 12
(6,346 Views)

Hi all,

 

Monday morning ... the week-end has not so efficient as expected.

 

Object of interest have been detected by the Detect objects function. Now we would like to record only those objects in a the output video and check if the size of this video fits our hardware capacity.

 

Any idea how to record those object. We tried to look on the Web and in the manual about programmatic ROI, but we found nothing relevant.

 

Any help will be more than welcome.

 

Kind regards

 

Mathieu

0 Kudos
Message 5 of 12
(6,315 Views)

I'm not exactly sure what you want. In the example I sent you, I show how to create a programmatic ROI using the ROI step. The ROI is based on the Detect Objects results, which returns the center of mass/width/height and the ROI step creates a programmatic ROI around that object and measures the colors using this programmatic ROI and log these results to disk. Then it uses an index step to do this for every object found by the detect objects step. Let me know if you were able to get the example I sent to work and how you're needing things to be different.

 

Thanks,

Brad

Message 6 of 12
(6,299 Views)

Hi Brad,

 

I have a look on the output file. It seems it returns Hue average, standard dev, min and max for each object.

In my opinion, we lost a lot information by this way (But it can be wrong).

 

What we would like to do, is reduce the size of the data. I'm thinking to two ways now (both based on Detect object):

 

The first one which can give us the position of each detected object and Hue Values for each pixel inside. Then we can record a file as the Brad's one in a .txt file for each image we have to process.

 

The second one could just consist consist to erase every Hue values of pixel located outside of the detected object: as transparent background in .png image.

 

I hope that it is more clear now. Let me know if you need additional explanation.

 

Regards

 

Mathieu

0 Kudos
Message 7 of 12
(6,281 Views)

Hi all,

 

we're also blocked because the CVS doesn't recognize the USB stick linked to the CVS.

 

We just plug the USB stick to the CVS (there are two USB 2.0 ports) but we're unable to write file on this USB Stick.

Is there someone who knows how to do?

 

We also saw that the image treatment with the CVS is very very slower than with a basic laptop. Did you get the same impresssion or not?

 

Regards

 

Mathieu

0 Kudos
Message 8 of 12
(6,274 Views)

Hi all,

 

autoreply.

 

the problem with USB stick has been solved.

 

Now, we would like to solve two problems:

- to keep only the ROI (as we axplained before in this discussion),

- to interger our .vbai in a .vi file (to manage to camera) at the same time and then to a .exe for a remote control.

 

We compiled .vbai to .vi but we still have some problem to integer those .vi as sub vi in a supervisor .vi file.

 

Any help is still welcome.

 

Regards

 

Mathieu

0 Kudos
Message 9 of 12
(6,266 Views)

Hi Mathieu,

 

Regarding you question regarding logging ROI. Did you take a look at the Log Object Results step to see what data can be logged?

 

Capture.PNG

 

 

Regarding your second question about converting from VBAI inspection to VI. Have you managed to migrate it to LabVIEW VI? Is the code working? Can you explain in more detail what problems you are facing with this code?

Regards,
Eirikur Runarsson
0 Kudos
Message 10 of 12
(6,213 Views)