MATLAB: Radius and coordinates of the center for a big circle in a bidimensional image

Image Processing Toolboximage segmentation

I have a bidimensional (N x N) matrix of pixels like the one shown in the attached figure. Black areas contain zero values, while other areas contain random non-zero values. How could I determine the radius (in pixels) and coordinates of the center for the big circle? Consider that its center doesn't correspond to the center of the matrix, like in the figure.

Best Answer

Get a binary image by thresholding. Then fill holes, label, and call regionprops().
binaryImage = grayImage > 10; % or whatever value works.
% Fill holes
binaryImage = imfill(binaryImage, 'holes');
% Label
labeledImage = bwlabel(binaryImage);
% Measure
measurements = regionprops(labeledImage, 'EquivDiameter');
% Extract
theRadius = measurements.EquivDiameter / 2;
By the way, instead of the very verbose and overly complicated "bidimensional (N x N) matrix of pixels", most people would simply just say "2D image".