Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Measureig length of shape changeing object

Hello I'm trying to measure the maximum length in IMAQ Vision Builder 6.0,of fish, which change shape. The camera has to be in about 45°. Any suggestion what I can do to measure it?
I have attached 3 pictures showing a sample what I am working with. Picture nr.
Download All
0 Kudos
Message 1 of 3
(3,341 Views)
Unnar,

I attached 3 images, one of them is Sample1 image you posted so you will see how I applied my algorithm to that one. I'm proposing here the 2 best ideas I thought about they might help you or hopefully someone else will give you other better ideas.

1. In picture fishCircle you will see how I applied the functions to find a circular edge on an image, first I binarized the image (thresholded) and applied a couple of morphological functions in order to isolate the fish from the rest of the image, now that I have the fish isolated I multiply it times 255 so I can have a grayscale image again, only with the fish I use the tool to find circular edge, you can see the image, it will give you the array of edges found, and the best circle, with radius
and center, so just use a geometry function for arc perimeter (with the leftmost and rightmost points of the array) and you are set.

2. On picture fishEdge, I use the same procedure to isolate the fish but then I use the function to find straight edge with a rake ROI, you will see that in the picture (is zoomed) the result is going to be an array of points so you have how many points you get, as well as the distance in between points since you set this distance in the configuration for this function, so distance times number of points you have total points on the longest side of the fish and then just do your own calibration as each pixel what is its measure in real world units.

I did not wanted to use the perimeter tool of binary, since if the mouth of the fish or fins are open or something it will give you higher perimeters, I say this in case you wanted to get total perimeter divided by two.

I hope this helps, good luck!

Regards,

Nestor Sanchez
IMAQ/Motion Support

National Instruments
Nestor
Download All
0 Kudos
Message 2 of 3
(3,341 Views)
Dear Nestor.
Thank you for your quick response.
I tried to make a script with your idea 1. When I run I get a picture a lot like the one you included in your answer. However I don't know how I can measure the length of the fish from that. And it looks like when I use another picture of another fish the circular edge does not come right, because the fish could turn the other way the next time.
I built another script with idea 2. I ran into the same problem there. Sometimes I have to use clockwise and sometimes counter-clockwise. Is there any way I can solve this?

Next I want to measure the length what tool can I use to get the best results?

I included the 2 scripts, 2 pictures and calibration image

Regards.

Unnar
Download All
0 Kudos
Message 3 of 3
(3,341 Views)