Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

IMAQ ROIProfile and Rotated Rectangle Region

Hello -

 

Consider the following.  rotated_rectangle.PNG

I have to draw a rotated rectangle region ROI on an image (as shown) and extract all of the lines that make up the region at the correct angle that the rectangle is rotated. In another words, all lines across the rectangle should be the same size and be angled at the same angle that the rectangle is rotated.

 

I cannot use IMAQ Rotate to make the image horizontal or vertical because it distorts the image.  This is unfortunate because it would allow me to extract the individual rows making up the regions by using the rectangle coordinates of the ROI.

 

After studying this problem for awhile, It is unclear to me how to extract this information from the outputs of IMAQ ROIProfile (or other method).

 

Can anyone provide some advice on this?

 

Don 

 

 

0 Kudos
Message 1 of 6
(5,118 Views)

My recommendation would be to use IMAQ Rotate. In my testing, this is not distorting the image; it's just rotating the array of points uniformly. When I use a max clamp between the lines before and after rotating the image, the distance is the same to within +/-.01 pixels (which is just me selecting the region slightly differently).

0 Kudos
Message 2 of 6
(5,096 Views)

There is a visual distortion when I use rotate which is why I hesitate to utilize this for quantitative analysis.  Take a look at the increased blur.  And I see it whether I have the option to maintian same size T or F.  What you see below is for 'maintain same size = F' because I was hoping the image processing software algorithm would be able to accomplish the same quality if I removed that constraint.

 

unrotated_rectangle.PNG

 

vs.

 

rotated_rectangle (2).PNGThis is the image I need but with the image quality of the unrotated image above.

0 Kudos
Message 3 of 6
(5,090 Views)
-The other way i would recommend is, identify the orientation of lines and make proper co-ordinate system and rotate the ROI's accordingly.
-check co-ordinate system examples might help.
-I think IMAQ rotate uses interpolation techniques while rotating and may be check what type of interpolation you are using.
Thanks
uday
Message 4 of 6
(5,070 Views)

Hello,

 

I do not see such a degree of blur using the IMAQ Rotate (probably because I don't have the original image). The IMAQ rotate uses Zero-order/Bilinear interpolation to fill the missing pixels.

You could alternatively use three shears rotation to rotate your image and make the vertical lines perpendicular to the horizontal base. It can be used in real-time also.

 

Below are the results for your image (rotation with bilinear interpolation):

 

rotate_FP.png

 

You should probably get better results using your original image with better resolution (this is taken from your post, so it's only 365x131). You get similar results using IMAQ rotate with zero-order interpolation.

 

Beware that the code is messy.

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Message 5 of 6
(5,068 Views)

Guys -

 

Thanks a lot for your help and have a happy Thanksgiving (if you celebrate it).  I have to think about this some more but I did realize that the excessive blurring I was getting using IMAQ Rotate was due to multiple rotation operations.  Finding the exact angle of orientation of the original, and then doing one IMAQ Rotate at the negative of that angle, is probably going to be my best option.  Then I can index the rows of the ROI after extracting the now-horizontal / properly-aligned ROI.

 

Sincerely,

 

Don

0 Kudos
Message 6 of 6
(5,054 Views)