Hello, I've been working on identifying the center point of images similar to the ones I've attached. I've tried using cornerHarris detector and various other operations, incl

1 Ansicht (letzte 30 Tage)

Antworten (1)

Image Analyst
Image Analyst am 5 Nov. 2023
See attached demos on shape recognition to find vertices.
First, extract the red channel and threshold it. Then use imfill to fill the shape. Then call regionprops to find the centroid.
It's a generic, general purpose demo of how to threshold an image to find blobs, and then measure things about the blobs, and extract certain blobs based on their areas or diameters.
  3 Kommentare
AADITYA DARAKH
AADITYA DARAKH am 5 Nov. 2023
is there a way in which i can find the corners of this image; or similar images where i have a particular shape drawn on hand ?
Image Analyst
Image Analyst am 5 Nov. 2023
Yes. I'd use one of my demos that I already attached that shows you how to get the shape, then find its centroid and boundary coordinates, then find the distances from centroid to boundary, then use findpeaks. Here is some pseudocode you can start with.
grayImage = rgbImage(:, :, 1); % Extract red channel.
mask = grayImage < 128; % Threshold to find dark blobs.
mask = imclearborder(mark); % Get rid of blobs touching the edge of the image (the shirt).
mask = imfill(mask, 'holes'); % Fill the shape.
mask = bwareafilt(mask, 1); % Take only the largest blob.
props = regionprops(mask, 'Centroid')
xCenter = props.Centroid(1);
yCenter = props.Centroid(2);
% Plot the borders of all the blobs in the overlay above the original grayscale image
% using the coordinates returned by bwboundaries().
% bwboundaries() returns a cell array, where each cell contains the row/column coordinates for an object in the image.
imshow(rgbImage); % Optional : show the original image again. Or you can leave the binary image showing if you want.
% Here is where we actually get the boundaries for each blob.
boundaries = bwboundaries(mask);
% boundaries is a cell array - one cell for each blob.
% In each cell is an N-by-2 list of coordinates in a (row, column) format. Note: NOT (x,y).
% Column 1 is rows, or y. Column 2 is columns, or x.
numberOfBoundaries = size(boundaries, 1); % Count the boundaries so we can use it in our for loop
% Here is where we actually plot the boundaries of each blob in the overlay.
hold on; % Don't let boundaries blow away the displayed image.
for k = 1 : numberOfBoundaries
thisBoundary = boundaries{k}; % Get boundary for this specific blob.
x = thisBoundary(:,2); % Column 2 is the columns, which is x.
y = thisBoundary(:,1); % Column 1 is the rows, which is y.
plot(x, y, 'r-', 'LineWidth', 2); % Plot boundary in red.
end
hold off;
caption = sprintf('%d Outlines, from bwboundaries()', numberOfBoundaries);
fontSize = 15;
title(caption, 'FontSize', fontSize);
axis('on', 'image'); % Make sure image is not artificially stretched because of screen's aspect ratio.
% Find distances from center to edges.
distances = sqrt((x - xCenter).^2 + (y - yCenter).^2);
% Find peaks
[peakValues, indexesOfPeaks] = findpeaks(distances)
% Plot them
hold on;
for k = 1 : numel(indexesOfPeaks)
plot(x(indexesOfPeaks), y(indexesOfPeaks), 'g.', 'MarkerSize', 50);
end
hold off;
Play with that. You may have to adjust some parameters, like the threshold or some findpeaks() options.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by