Matrix Rotation for pressure values comparison

2 views (last 30 days)
Hi,
I have the following plot:
I need to rotate the foot counter-clockwise so the foot stay in a vertical position. However I am not interested in rotating the image but the matrix values (34x18) . Basically I need to compare the foot of two subjects but for that I need to be able to put the foot data in the right position (trought rotation), so that the foot areas of one subject match the foot areas of the other subject. Any ideas about how to perform this rotation?

Answers (2)

Star Strider
Star Strider on 3 Oct 2015
If you use the contour function (or its friends), you can get the information on the various contours and contour levels from the output of the function, if you ask for it. (You can use the same data you used to do the surf plot, with much the same format.) Those will give you the approximate (x,y) values for all the contours. You can then search for the highest contour. (You can also choose to limit the number of contours or specify a particular single contour to plot and return.)
Read the documentation and experiment to get the result you want. Pay particular attention to the way the contour data are formatted. All the information is there, but you have to write the code to look for it and isolate the part you want. You can then get the approximate centres of the highest contours from those data, since they appear to be the information you want.
  2 Comments
Armindo
Armindo on 4 Oct 2015
Hi,
Thank you for the help. I already try something like that but I was unable to understand how to do it right. Meanwhile Image Analyst told me that it might be possible to use the regionprops(), or by using the radon transform.
I'm trying to understand how to do this, but until now no luck. Image Analyst told me that he can provide me a demo about the radon transform rotation which should help.
You can specify a little more your aproach about the rotation with the contour? Note that is also important to maintain the scale.
Star Strider
Star Strider on 4 Oct 2015
My pleasure.
However it is never a good idea to cross-post to the Newsgroup and to Answers. This is an xor situation! I haven’t done anything with the Newsgroup in nearly four years, so I never think to look there.
I’ll let Image Analyst address your concerns about his suggestions.
My approach uses the fact that contour creates a contour of (x,y) coordinates for each contour. Like all real-world data analysis, you will have to experiment a bit to see what gives you the best results.
I would:
  1. Determine the range of pressures in your matrix (use the sort function);
  2. Use the sort function to locate the highest 5% (or less) of your pressure data in the matrix simply to see what the values are;
  3. Specify that contour draw contours at two or more of those levels (for example 95% and 99%) in your contour plot (limiting the levels makes it easier to work with the data, see the documentation on contour for details);
  4. Get the (x,y) data from those contours;
  5. Take the mean of the (x,y) data for each contour, since this should give you the approximate centroids of each of those contours;
  6. Choose the contour level result that best describes the data you want to analyse;
  7. Use those data in your analysis.
I don’t understand your wanting to rotate them, though. I would simply take the distance between them (use the hypot function) and the angle if necessary (use the atan2 function), and be done with it. Those data and the pressure data should be all you need.

Sign in to comment.


Image Analyst
Image Analyst on 4 Oct 2015
Attached is a program that uses the radon transform to figure out the angle that the object is aligned along, and rotate the image to "straighten" it to align with the edges of the image:
Of course, in your case you have to use the original grayscale pressure image, not the pseudocolored image.
Alternatively you can threshold the image and find the major axis with regionprops
binaryImage = grayScaleImage > 10; % or whatever.
% Perhaps call bwareafilt() if you need to remove small noise blobs.
% Get the convex hull to join separate blobs into one, if necessary.
binaryImage = bwconvhull(binaryImage, 'union');
labeledImage = bwlabel(binaryImage);
measurements = regionprops(labeledImage, 'Orientation');
Then rotate the image
rotatedImage = imrotate(grayScaleImage, -measurements.Orientation);
or you can use (90 - measurements.Orientation) depending on what direction you want to go.
  5 Comments
Image Analyst
Image Analyst on 4 Oct 2015
It looks like you're using pcolor(). I would not do that. Use imshow() and put "axis on" so you can see the actual pixels, instead of "who knows what" that you passed in to pcolor. If you have square pixels in your sensor then it should be fine. If your pixels are not square, then you should recalculate the image size to compensate for that and give you square pixels.
Armindo
Armindo on 5 Oct 2015
I am using the surf plus contour3 and my pixels are not square (0.254 x 0.381). Due the calculations and comparisons that I need to perform it would be better to maintain this sensor size (and not use square pixels). But the interpolation (using the imrotate) seems to be changing the initial values. Is not possible to maintaing the same (x, y) interval when rotating the image? Using the imshow with "axis on" I get these images below (at left before rotation) and (at right after rotation) and after rotation I dont get a very nice image.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!