MATLAB Answers

How to find the inclination of the back bone in the attached image?

조회 수: 5(최근 30일)
Mrutyunjaya Hiremath
Mrutyunjaya Hiremath 2020년 5월 17일
댓글: Image Analyst 2020년 8월 22일
Hello Everyone... Greetings...
I am working with some medical imaging problems.
I want to rotate the given image after finding the inclination angle,
So that backbone looks straight and performs further steps.
I have attached the image for the reference.
The image is high resolution with low quality.
Can anyone suggest, how to find the inclination of the backbone?
Thank you.

채택된 답변

Ryan Comeau
Ryan Comeau 2020년 5월 19일
편집: Ryan Comeau 2020년 5월 20일
I am thinking the best way to do this will be analog. What i mean is just choose two sets of coordinates, compute their slope and apply the rotation yourself. It will be the least painful if you don't need to repeat this frequently.
Doing this autonomously will be quite a bit more difficult. There are ways to get it done, but guarenteeing good performance over your analog work will be difficult. Here is the way to do this analog:
%you choose 2 coordinate sets on the image
slope=(coord_1(2)-coord_2(2))/(coord_1(1)-coord_2(1)); %simple slope calculation
%now we convert this to degrees.
%assuming 90 is vertical and 0 is horizontal
%perform the rotation
Now to do this autonomouly will require some work. You will need to apply an image processing technique to segment the objects present, and identify the spine. You'll need to play around with the methods to see which one works the best. Here are some ideas that I have:
  1. Use a hough transform,this algorithm identifies lines in an image(see: Locate the longest line(which should be the spine, calculate its slope and perform the rotation). Try processing without the image pre processing ans see if you can detect the spine.
%code for the Hough transform
%this block gives the endpoints of the lines it locates.
%try the Hough transform without the pre processing as well.
image=rescale(image,0,1);%helps in binarization
BW_finel=bwskel(BW_im); %create image skeleton
[H,theta,rho] = hough(BW_final);
P = houghpeaks(H,45,'threshold',ceil(0.1*max(H(:))));
lines = houghlines(BW_im,theta,rho,P,'FillGap',5,'MinLength',7);
%lines is a struct, stick this in a for loop to extract
for i=1:length(lines)
%parse for the longest one to identify the spine.
2. Use Haar like features
All of these methods except 4, will require you to parse the output and figure out the slope of the spine, then apply the rotation. A Haar like feature(just google these), can be used to identify objects. Here, we will construct one for the spine, and rotate it in intervals of 5 degrees(you can change this). The Haar like features will convolute the image, and whichever angle yields the highest value(from the convolution) will give a +-2.5 degrees on your spine angle. The following block of code explains how to use a Haar like feature and the logic to determine the rotation.
image=rescale(image,0,1); %helps with speed and other things
spine_average_width=30; %this is in pixels, change for your need(tune it)
spine_average_height=100;% in pixels change for your need(tune it)
%we have created a binari image with a vertical bar. this is our Haar like feature
%you'll need to add a little routine to make sure the rotation is upwards
for i=1:18 %starting from vertical going horizontal
angle=index*5; %because 5 degrees per iteration
I hope this answer is not overbearing, i just like medical imaging problems and think they're fun to solve.
Hope this helps,
  댓글 수: 2
Ryan Comeau
Ryan Comeau 2020년 5월 20일
I've updated the answer with some more Hough transform details.

댓글을 달려면 로그인하십시오.

추가 답변(1개)

Image Analyst
Image Analyst 2020년 5월 20일
I disagree with the accepted answer. Perhaps he's never heard of the radon transform - the Nobel prize winning medical imaging algorithm that is at the heart of CT and MRI. You can do this automatically just by taking the radon transform and looking for the peak.
See my attached demo. Adapt as needed by applying the FAQ: FAQ How_can_I_process_a_sequence_of_files? for your hundreds of images.
  댓글 수: 4
Image Analyst
Image Analyst 2020년 8월 22일
Girish, start a new question - let's not hijack this one. Post your image there and a definition of what direction you consider to be the "height".

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by