How to Select ROI based on this algorithm. OR how can i segment only the bone part from these images.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (4)
Constantino Carlos Reyes-Aldasoro
il 20 Lug 2018
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
il 20 Lug 2018
A problem, I do not have labeledImage
biggestBlob = ismember(labeledImage, sortIndexes(1:numberToExtract));
Undefined function or variable 'labeledImage'.
Guillaume
il 20 Lug 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 Commenti
Guillaume
il 20 Lug 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');
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!