11-25-2014 01:17 PM
Hello -
Consider the following.
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
11-26-2014 01:16 PM
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).
11-26-2014 01:48 PM
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.
vs.
This is the image I need but with the image quality of the unrotated image above.
11-27-2014 05:10 AM
11-27-2014 05:40 AM - edited 11-27-2014 05:45 AM
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):
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
11-27-2014 10:46 AM - edited 11-27-2014 10:50 AM
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