Calculate the measurements of a Binary Image with an ndims of 3

조회 수: 1 (최근 30일)
Ryan Tigera
Ryan Tigera 2020년 11월 16일
댓글: Ryan Tigera 2020년 11월 19일
I am analyzing a series of images that increase the volume of the yellow plume over a series of time steps. My goal is to compare the area, centroid, outline and lengths of the largest finger of each yellow plume with other similiar images in a table as well as have MATLAB show the centroid and extrema on the image. In order to measure these properties, Matlab states I need a ndims of 2 or less where my binary image is 3. I used the imbinarize command to create a binary image and I recieved this error using regionprops.
An example of the photo to be analyzed is attached to this post.
Thanks for your help.
Ryan
  댓글 수: 2
Rik
Rik 2020년 11월 16일
Did you convert the RGB image to grayscale before binarizing?
Ryan Tigera
Ryan Tigera 2020년 11월 19일
Hi Rik,
Thanks for the help. In reviewing my code, I skipped this step.
Thanks again for your help.

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

답변 (1개)

Shashank Gupta
Shashank Gupta 2020년 11월 19일
편집: Shashank Gupta 2020년 11월 19일
Hey Ryan,
you might need to convert your RGB image to Gray image first and then binarize it, this will make sure you have ndim equals to 2. Attaching a small piece of code for your referece.
% Read image
img = imread('A,T=8min,V=40mL,TR.JPG');
% Convert RGB to gray.
im = rgb2gray(img);
% Binarize.
im = imbinarize(im);
% Use regionprop function according to your necessity.
stats = regionprops('table',im,'Centroid',...
'MajorAxisLength','MinorAxisLength')
Hope this helped.
Cheers.
  댓글 수: 3
Shashank Gupta
Shashank Gupta 2020년 11월 19일
Yes rik, my mistake, I will edit it and correct it. Thank for noticing.
Ryan Tigera
Ryan Tigera 2020년 11월 19일
Thanks to you both. This has resolved my issue

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by