Can anyone help me to solve this error in regionprops().

조회 수: 3 (최근 30일)
MINO GEORGE
MINO GEORGE 2021년 5월 24일
답변: Walter Roberson 2021년 5월 25일
This is the code.The stats is a table, in that MajorAxisLength() and MinorAxisLength() is showing as 0*0 (double)
gray = imread('CYST RENAL-37.jpg');
grayImage = rgb2gray(gray);
level = graythresh(gray);
BW = imbinarize(gray,level);
stats = regionprops('table',BW,'Centroid',...
'MajorAxisLength','MinorAxisLength');
centers = stats.Centroid;
diameters = mean([stats.MajorAxisLength stats.MinorAxisLength],2);
radii = diameters/2;
Pls help me to solve this error. Any help is appreciated
  댓글 수: 3
Walter Roberson
Walter Roberson 2021년 5월 24일
Also I wonder if using "equivalent diameter" property would happen to be appropriate for your case.
MINO GEORGE
MINO GEORGE 2021년 5월 25일
Thank you for responding.
I need to segment the cyst region (black hole) from the kidney ultrasound image. The image is attached here. When i execute this code, i am getting these many errors.
Error using sum
Invalid data type. First argument must be numeric or logical.
Error in mean (line 127)
y = sum(x, dim, flag) ./ mysize(x,dim);
Error in subtract (line 13)
diameters = mean([stats.MajorAxisLength stats.MinorAxisLength],2);
Thanks for the help

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

답변 (1개)

Walter Roberson
Walter Roberson 2021년 5월 25일
gray = imread('CYST RENAL-37.jpg');
grayImage = rgb2gray(gray);
BW = imbinarize(grayImage);
stats = regionprops('table',BW,'Centroid',...
'MajorAxisLength','MinorAxisLength');
centers = stats.Centroid;
diameters = mean([stats.MajorAxisLength stats.MinorAxisLength],2);
radii = diameters/2;
You were trying to imbinarize() the RGB image, not the gray image.
Also, imbinarize() automatically determines the threshold by calling graythresh if you do not pass in a level.

카테고리

Help CenterFile Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by