Why regionprops didn't work?

2 visualizaciones (últimos 30 días)
Andrea Vezzoli
Andrea Vezzoli el 25 de Dic. de 2016
Editada: Walter Roberson el 26 de Dic. de 2016
Hi all,
I want to use regionprops function to detect a hole inside a grayscale image I wrote this code:
I=imread('nameimg')
I=im2bw(I)
g=regionprops(I,'centroid')
Why this code make this error:"Too many input argument"??????
Thanks all
  1 comentario
John BG
John BG el 25 de Dic. de 2016
please make the image available by attaching it to your question

Iniciar sesión para comentar.

Respuesta aceptada

Image Analyst
Image Analyst el 25 de Dic. de 2016
Try this
grayImage = imread('nameimg.png');
% Get the dimensions of the image.
% numberOfColorChannels should be = 1 for a gray scale image, and 3 for an RGB color image.
[rows, columns, numberOfColorChannels] = size(grayImage);
if numberOfColorChannels > 1
% It's not really gray scale like we expected - it's color.
% Use weighted sum of ALL channels to create a gray scale image.
grayImage = rgb2gray(grayImage);
% ALTERNATE METHOD: Convert it to gray scale by taking only the green channel,
% which in a typical snapshot will be the least noisy channel.
% grayImage = grayImage(:, :, 2); % Take green channel.
end
% Display the image.
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize, 'Interpreter', 'None');
binaryImage = im2bw(grayImage);
[labeledImage, numBlobs] = bwlabel(grayImage);
props = regionprops(labeledImage,'Centroid')
allCentroids = [props.Centroid];
xCentroids = allCentroids(1:2:end);
yCentroids = allCentroids(2:2:end);

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by