Borrar filtros
Borrar filtros

Detect Shape in Image and How many times shapes come in Image

5 visualizaciones (últimos 30 días)
Med Future
Med Future el 27 de Mzo. de 2022
Comentada: Med Future el 31 de Mzo. de 2022
Hello Everyone, I hope you are doing well.
I have the following image i want to detect the shape in the image and count how many time shapes exist for example in image im_003002 (1) The peroidic shape which comes six time, i want to detect the shape and show the shapes exist 6 time in the image. similarly in im_005001 (1) the shapes comes 7 times
Can any body help me in this please
  2 comentarios
KSSV
KSSV el 27 de Mzo. de 2022
You have asked this question already.
Med Future
Med Future el 27 de Mzo. de 2022
@KSSV, I can't get answer there that's why I asked again.

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 27 de Mzo. de 2022
Did you try bwlabel()? If mask is the second image with the slanted lines:
[labeledImage, count] = bwlabel(mask);
  7 comentarios
Image Analyst
Image Analyst el 28 de Mzo. de 2022
Here is my code with your image. You can see there are 7 regions.
% Demo by Image Analyst
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 16;
markerSize = 40;
%--------------------------------------------------------------------------------------------------------
% READ IN IMAGE
folder = pwd;
baseFileName = 'im_005001 (1).png';
% baseFileName = 'image_2732.png';
fullFileName = fullfile(folder, baseFileName);
% Check if file exists.
if ~exist(fullFileName, 'file')
% The file doesn't exist -- didn't find it there in that folder.
% Check the entire search path (other folders) for the file by stripping off the folder.
fullFileNameOnSearchPath = baseFileName; % No path this time.
if ~exist(fullFileNameOnSearchPath, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
rgbImage = imread(fullFileName);
% 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(rgbImage)
if numberOfColorChannels > 1
% It's not really gray scale like we expected - it's color.
fprintf('It is not really gray scale like we expected - it is color\n');
% Extract the blue channel.
grayImage = rgbImage(:, :, 3);
else
grayImage = rgbImage;
end
%--------------------------------------------------------------------------------------------------------
% Display the image.
subplot(2, 1, 1);
imshow(grayImage);
impixelinfo;
axis('on', 'image');
title('Original Gray Scale Image', 'FontSize', fontSize, 'Interpreter', 'None');
% Maximize window.
g = gcf;
g.WindowState = 'maximized';
drawnow;
%--------------------------------------------------------------------------------------------------------
% Binarize the image to get a mask.
mask = imbinarize(grayImage);
% Display mask image.
subplot(2, 1, 2);
imshow(mask);
hold on;
impixelinfo;
axis('on', 'image');
drawnow;
title('Binary Image', 'FontSize', fontSize, 'Interpreter', 'None');
% Count the number of slanted regions.
[labeledImage, numRegions] = bwlabel(mask);
% Tell the user
message = sprintf('Number of regions = %d', numRegions);
title(message, 'FontSize', fontSize, 'Interpreter', 'None');
uiwait(helpdlg(message))
Med Future
Med Future el 31 de Mzo. de 2022
@Image Analyst Its not working on second image, I want it to work for the second image eg im_003002 (1)

Iniciar sesión para comentar.

Categorías

Más información sobre 3-D Volumetric Image Processing en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by