How do I find the centre of gravity for an irregular shape?

조회 수: 27 (최근 30일)
Sudev Parthiban
Sudev Parthiban 2019년 7월 2일
댓글: Sudev Parthiban 2019년 7월 17일
I have given the marked coordinates and region of interest in which I would like to find the centre of gravity for, please help me.
  댓글 수: 2
Jan
Jan 2019년 7월 2일
In which format are the input data given?
Sudev Parthiban
Sudev Parthiban 2019년 7월 15일
편집: Jan 2019년 7월 15일
It is an ultrasound image it is in .mat format... This is my code:
clc
clear
close all
cd('C:\Users\ADMIN\Desktop\Sudev\Objective 1')
load('ROI1.mat'); %Load data from file
figure(1); clf;
subplot(1,2,1);
imshow(paveikslas,[])
paveikslas(1:200,1:200,:) = 0;
figure(1); clf;
subplot(1,2,1);
imshow(paveikslas,[])
hold on
plot(x_poly, y_poly,'r','LineWidth',2)
title('Overlap of ROI on Bscan')
subplot(1,2,2);
plot(x_poly); hold on;
plot(y_poly,'-r');
title('Coordinates of ROI')
figure(2)
plot(x_poly, y_poly,'r','LineWidth',2)
axis equal
title('ROI to be calculated for Center and Axis')

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

채택된 답변

Bruno Luong
Bruno Luong 2019년 7월 15일
You can get the coordinates of the centroid if you have a boundary coordinates of a polygonal region:
[xc,yc] = polygoncentroid(x_poly,y_poly)
using this function
function [xc,yc] = polygoncentroid(x,y)
xn = circshift(x,-1);
yn = circshift(y,-1);
A = x.*yn-xn.*y;
a = 3*sum(A);
xc = sum((x+xn).*A)/a;
yc = sum((y+yn).*A)/a;
end

추가 답변 (1개)

Kaustav Bhattacharya
Kaustav Bhattacharya 2019년 7월 2일
  댓글 수: 4
Sudev Parthiban
Sudev Parthiban 2019년 7월 15일
It is in DICOM format.
Jan
Jan 2019년 7월 15일
편집: Jan 2019년 7월 15일
The DICOM format is a file format. You have loaded the data from a MAT file. Therefore I think, that "DICOM format" is neither possible, nor does it explain, how the data are represented. All we know currently is that your data are not a binary image. Please provide any explicit details about the input. It would be inefficient if the readers guess, which data you have.
What do you exactly get for:
data = load('ROI1.mat')
Loading data directly into the workspace is prone to bugs. Prefer to catch the data in a variable like in my example.

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

카테고리

Help CenterFile Exchange에서 DICOM Format에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by