Calculation of centroide of an object in image
5 ビュー (過去 30 日間)
古いコメントを表示
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1692281/image.jpeg)
i am currently working on a school project of medical image. I have an x-ray image of a head in lateral position with a brain tumor. i have to calculate the centroide of this tumor. the tumor has an higher contrast however so does other objects in the image. how can i do it?
thank you everyone in advance.
i don't have much experience with matlab so i am a bit in a struggle
4 件のコメント
DGM
2024 年 5 月 11 日
編集済み: DGM
2024 年 5 月 11 日
What exactly do you mean when you say "higher contrast"? I'm no radiologist, but from the handful of images I've played with, I wouldn't think local contrast (i.e. a measure of variation) would abnormally high in tumor regions. A lot of the tumor images I've seen have very low contrast in tumor regions.
Maybe when you say "higher contrast" you mean the brighter regions? (Maybe that's a difference between radiology terms and more general image processing terminology). It might still be ambiguous, as there are also other bright regions, but we need to know which bridge we're even trying to cross.
Also, does the process need to be automated, and if so, to what degree?
DGM
2024 年 5 月 11 日
I'm going to throw this out there based on the assumption I mentioned. This is not entirely automated, but the interactive part means I can't run it on the forum.
% read the image
inpict = imread('image.jpeg');
inpict = im2gray(inpict); % grayscale
% manually create a crude polygon selection loosely around the tumor
% it only needs to include the tumor and exclude non-tumor bright regions
imshow(inpict);
ROI = drawpolygon(gca);
roimask = createMask(ROI);
% threshold the entire image
% based on the intensity distribution in the ROI
thresh = graythresh(inpict(roimask));
mask = imbinarize(inpict,thresh);
% refine the mask by excluding blobs outside the roi
mask = mask & roimask;
% select the largest blob in the mask
mask = bwareafilt(mask,1);
% should the holes in the blob be left open or not?
% i'm going to fill them.
mask = imfill(mask,'holes');
% show the mask
imshow(mask)
% get the centroid (or other properties)
S = regionprops(mask,'centroid');
% plot the calculated centroid on the original image
figure
imshow(inpict); hold on
plot(S.Centroid(1),S.Centroid(2),'gx','markersize',20,'linewidth',3)
Otherwise, trying to find any tumor in any image without the constraint provided by the human guidance is not a simple problem.
回答 (1 件)
Image Analyst
2024 年 5 月 11 日
It's a generic, general purpose demo of how to threshold an image to find blobs, and then measure things about the blobs, and extract certain blobs based on their areas or diameters.
Also, see my attached demo. Adapt as needed.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1692331/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1692336/image.png)
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!