How to Select ROI based on this algorithm. OR how can i segment only the bone part from these images.

2 Ansichten (letzte 30 Tage)
Algorithm:
1. Start
2. Read input image, I
3. Resize the input image I, by a scale of 0.15 to get the
resized image Iresized.
4. Apply Otsu segmentation [14] to the image, Iresized.
5. Calculate area of every region in the threshold image,
Iotsu.
6. Select the region with maximum area as the ROI.
7. Calculate its inclination.
8. Correct the inclination of the bone using the formula
8.1. If the bone is inclined to the right, then it is rotated
in anti-clockwise direction by an angle equal to
90-angle(i.e. Anglecorrected = 90 - Angleoriginal)
8.2. But if the bone is inclined to the left, then it is
rotated in clockwise direction by an angle equal to
-90-angle(i.e. Anglecorrected = - 90 -
Angleoriginal). Here the value obtained will be
negative. This denotes that the image should be
rotated in clockwise direction.
9. The new image obtained is Irot. Next, the co-ordinates of
the bounding box of the maximum area region in the
above image are obtained.
10. Using these coordinates a rectangle containing the bone
region (ROI) is cropped from the image Irot. The new
image obtained is Icrop, which is the final pre-processed
image Inew.
11. Stop
A sample of this result is shown in Results.png (its according to a paper : https://pdfs.semanticscholar.org/8ea1/eeea2f00c58a6a9a959355d6cc8eebf686cd.pdf). I Wanted the same for my database of images, a sample of images are 12490, 2425 and 8823. I tried the below code till step 9.
I=imread('12493.png');
J = imresize(I, 0.5);
imshow(J);
level = graythresh(J); % Global image threshold using Otsu's method
BW = imbinarize(J,level);
imshowpair(J,BW,'montage')
blobMeasurements = regionprops(BW, 'area'); % Area of objects in binary image
% Get all the areas
allAreas = [blobMeasurements.Area];
[sortedAreas, sortIndexes] = sort(allAreas, 'descend');
numberToExtract=1;
biggestBlob = ismember(BW, sortIndexes(1:numberToExtract));
imshow(biggestBlob); % max ROI
stats = regionprops(BW,'Orientation'); % Inclination
Angleoriginal=stats(1).Orientation;
if Angleoriginal<90
Anglecorrected = 90 - Angleoriginal;
else
Anglecorrected = -90 - Angleoriginal;
end
I_rot = ismember(biggestBlob, Anglecorrected);
imshow(I_rot); % I rot image (step 9)
Now I am getting a black squared output at this stage after step 9? Where i have gone mistake and how to further continue..
  3 Kommentare
Karthik K
Karthik K am 24 Jul. 2018
Bearbeitet: Karthik K am 24 Jul. 2018
ok. since i did not get any reply from you back. i edited this and posted a new question again. Here many replies are there which are not useful to get it in one stretch. I am still not able to solve the last 2 steps.
Number of views are simply increasing if the page is got refreshed. Not able to get any kind of hints or solutions.
Since i am beginner in solving an algorithm in matlab, you comment for beginners as does not make any sense at all., which i myself felt bad. and i said i will follow according to you, but was unable to get any hint or suggestion or help from you further.

Melden Sie sich an, um zu kommentieren.

Antworten (4)

Constantino Carlos Reyes-Aldasoro
In order to be able to help, we would need to run the code and find the error, and that is not possible without the image
I=imread('12493.png');

Constantino Carlos Reyes-Aldasoro
A problem, I do not have labeledImage
biggestBlob = ismember(labeledImage, sortIndexes(1:numberToExtract));
Undefined function or variable 'labeledImage'.

Constantino Carlos Reyes-Aldasoro
Ok, good that you have sorted the problem.
  1 Kommentar
Karthik K
Karthik K am 20 Jul. 2018
Bearbeitet: Karthik K am 20 Jul. 2018
Still my output image is black. i did not found the solution. just answered your query. variable was different.

Melden Sie sich an, um zu kommentieren.


Guillaume
Guillaume am 20 Jul. 2018
Now I am getting a black squared output at this stage after step 9?
Well, no wonder considering that your step 9 is:
I_rot = ismember(biggestBlob, Anglecorrected);
which makes absolutely no sense. I can't even begin to understand why you'd think ismember would be useful here.
If you wanted to implement a rotation:
I_rot = imrotate(biggestBlob, Anglecorrected);
  4 Kommentare
Guillaume
Guillaume am 20 Jul. 2018
stats = regionprops(I_rot,J,'BoundingBox')
Again, that makes no sense at all. You can't pass a rotated and unrotated image together to regionprops. The two must match. Even if the two images were the same size, conceptually that is just wrong. The two arguments must be the labelled and unlabelled version of the same image.
You really need to reflect on the code you write because so far, the error you get are because what you wrote simply doesn't make sense.
If you just want the bounding box of the objects in the rotated image:
stats = regionprops(I_rot, 'BoundingBox');
Karthik K
Karthik K am 20 Jul. 2018
Bearbeitet: Karthik K am 20 Jul. 2018
I am a beginner to matlab in solving an algorithm sir. Trying it. I will go with you, can you tell me how to further solve with steps 9 and 10 of the algorithm. so that for my input image, i get the output as per the Results.png image. now the input image and output image is attached.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by