MATLAB Answers

How to classify images depending on the shape of each image's object ?

3 views (last 30 days)
Mohamed Elbeialy
Mohamed Elbeialy on 21 Apr 2021
Commented: Amit on 5 Jun 2021
  6 Comments
Amit
Amit on 5 Jun 2021
Follow following steps,
  1. First of all you need to binarize the image and find edges of image using canny edge detection.
  2. Then you need use regionprops to extract various isolated regions in the image.
  3. You need to find centroid of regions.
  4. Then at various angles, you can find distance between centroid of region and point on edge of image.
  5. This makes your shape descriptors.
  6. You can compare these descriptors with descriptors of known share to categorize your query or unkown object.
This should work for you.
I have my IEEE paper published regarding above process, you can send request to me on, amit.kenjale@gmail.com, I will send you my IEEE paper where this process is explained in details with images showing intermediate results.

Sign in to comment.

Answers (3)


Image Analyst
Image Analyst on 24 Apr 2021
Try the transfer learning example with CNN/AlexNet. There should be demos in the Deep Learning Toolbox.
  30 Comments
Image Analyst
Image Analyst on 27 Apr 2021
To get a binary image mask of inside where you traced the outline:
binaryImage = grayImage < someValue;
You'd have to train (label) your training images all with the outline and with the class you know them to be (car, dog, etc.)

Sign in to comment.


Walter Roberson
Walter Roberson on 25 Apr 2021
imageInputLayer([227 227 3],"Name","data","Normalization","rescale-zero-one")
This will rescale each input image to have a maximum value of 1.
  20 Comments
Image Analyst
Image Analyst on 27 Apr 2021
You asked: "I do find the code for detecting object inside image, but I do not know how to apply to the whole imageDatastore." So, try this:
ds = imageDatastore('*.png')
numFiles = numel(ds.Files)
% Apply "code for detecting object inside image" to "the whole
% imageDatastore" - apply to every image in the image datastore.
for k = 1 : numFiles
thisFullFileName = ds.Files{k};
fprintf('Analyzing #%d of %d : "%s" ...\n', k, numFiles, thisFullFileName);
theImage = imread(thisFullFileName);
imshow(theImage);
[folder, baseFileNameNoExt, ext] = fileparts(thisFullFileName);
title(baseFileNameNoExt, 'Interpreter', 'none');
drawnow;
% Now give code to do something to analyze theImage...
% Put your existing code "for detecting object inside image" here:
end

Sign in to comment.

Tags

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by