How can i improve, like shape detecting then exracting edges?

1 次查看(过去 30 天)
I made an algorithm to detect a leaf boundary. Is that enough? Should I add something more? How can i improve, like shape detecting then exracting edges?
clc
clear all
close all
leaves= imread('leaf.jpg');
%%Extract each color Next we using indexing to extract three 2D matrices
%from the 3D image data corresponding to the red, green, and blue components of the image%
r = leaves(:, :, 1);
g = leaves(:, :, 2);
b = leaves(:, :, 3);
figure %View different color planes
subplot(2,2,1),imshow(r),title('R Plane')
subplot(2,2,2),imshow(g),title('G Plane')
subplot(2,2,3),imshow(b),title('B Plane')
%%Calculate Green Then we perform an arithmetic operation on the matrices as
%a whole to try to create one matrix that represents an intensity of green.%
justGreen = g - r/2 - b/2;
%imshow(justGreen)
close all
%Threshold the image Now we can set a threshold to separate the parts of
%the image that we consider to be green from the rest.%
bw = justGreen > 30;
%imshow(bw)
%%Remove small unwanted objects%
close all
bw1 = bwareaopen(bw, 30);
%imshow(bw1)
% morfolojik düzeltme
se = strel('disk', 10); % resimdeki yaprağın büyüklüğüne göre değer değişmeli, büyük değer ayrıntıları bozuyor
bw2 = imclose(bw1, se);
%imshow(bw2)
%%yeşil kısmı ayrılmış resmin binary görüntüsü ile birleşimi
bw3 = im2bw(bw,0.01);
bw3 = bw3 | bw2
bw3 = imclose(bw3, se);%morfolojik kapama
imshow(bw3)
%%Filling holes of the image
fillResim = imfill(bw3,'holes');
imshow(fillResim)
%%edge detection
close all
edges= edge(fillResim);
imshow(edges),title(' kenarlar ')

回答(1 个)

Image Analyst
Image Analyst 2018-1-3
If it's enough for you, then it's enough for me.
If you're looking for suggestions on how to make it fancier (nicer image, graphs, etc.) or more robust, explicitly ask for things like that and then post your image.

类别

Help CenterFile Exchange 中查找有关 Image Segmentation and Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by