MATLAB Answers

How can I remove unwanted objects and segment the swan?

3 ビュー (過去 30 日間)
Jichen Zhao
Jichen Zhao 2019 年 12 月 7 日
Commented: Jichen Zhao 2019 年 12 月 7 日
There are 16 images containing the swan logo. I need to recognise and segment the swan, generate a binary image where zero means no swan detected and a non-zero value means that the pixel belongs to the swan logo as shown in the figure below. I need to write an automatic and robust method that is able to accurately detect the swan logo from all/most provided images.
I can apply colour thresholding; carry out connected component analysis to extract regions of interest. However, I don't know how to use region and shape features to recognise the segments that belongs to a swan. Currently, I can get a binary image with the swan logo and many unwanted objects. The requirements say that It should NOT involve any training (i.e. a machine learning based approach).
Can anyone help me with this? The following is my code:
clear;
close all;
clc;
I = imread('IMG_08.jpg');
Igrey = rgb2gray(I);
Igrey_new = imresize(Igrey, 0.5, 'bilinear');
%{
figure;
imshow(Igrey_new);
%}
Igrey_filter = imtophat(Igrey_new,strel('disk',35));
%{
figure;
imshow(Igrey_filter);
%}
Igrey_bw = imbinarize(Igrey_filter);
se = strel('disk', 2);
Igrey_bw = imopen(Igrey_bw, se);
Igrey_bw = imfill(Igrey_bw, 'holes');
Igrey_bw = bwareaopen(Igrey_bw, 1000);
figure;
imshow(Igrey_bw);
Igrey_label = bwlabel(Igrey_bw);
stats = regionprops(uint8(Igrey_label), 'Area', 'Circularity');
disp([stats.Area]);
disp([stats.Circularity]);
Igrey_swan = ismember(Igrey_label, find([stats.Area] < 31000 ...
& [stats.Circularity] > 0.12 ...
& [stats.Circularity] < 0.23));
Igrey_swan = imclearborder(Igrey_swan);
figure;
imshow(Igrey_swan);

  0 件のコメント

サインイン to comment.

件の回答 (1)

Image Analyst
Image Analyst 2019 年 12 月 7 日
編集済み: Image Analyst 2019 年 12 月 7 日
You can do with functions in the Computer Vision Toolbox.
you mgiht also look at Hus moments: http://www.youtube.com/watch?v=Nc06tlZAv_Q

  3 件のコメント

Jichen Zhao
Jichen Zhao 2019 年 12 月 7 日
Thanks much! But how can I achieve this only in a script file? That is, automatically recognise and segment the swan logo.
Image Analyst
Image Analyst 2019 年 12 月 7 日
The functions in the toolbox can be typed into a script file.
Jichen Zhao
Jichen Zhao 2019 年 12 月 7 日
Yeah, I have tried that. It's handful but I'm asked to accomplish the task as accurately as possible using Matlab built-in function and the process should not be very complicated. Besides, learning is not allowed so I guess I can simply do recognition and segmentation based on properties of labelled objects. I just don't know how to do it.

サインイン to comment.

サインイン してこの質問に回答します。


Translated by