0
$\begingroup$

I am a novice in image processing. As a part of my school project, I have to do the following steps in Matlab on the below image.

LEAF

  1. Detect the edges of a leaf.
  2. Calculate the area of a leaf (excluding the stem portion)

My friend suggested me an idea of calculating the total number of pixels in the leaf (excluding stem portion) divided by the number of pixels per cm2.

But I don't know how to do these in Matlab. Someone, please guide me.

$\endgroup$
0
$\begingroup$

I took the steps that @Filipe Pinto mentioned and implemented few of them. Here is the code and results.

leaf = imread('YV5LD.jpg');

leaf_gray = rgb2gray(leaf);
% binarize
leaf_bin = leaf_gray < 80;

se = strel('line',11,90);

% eroded image
erodedBW = imerode(leaf_bin,se);

figure
imshowpair(leaf_gray, leaf_bin, 'montage')
figure
imshowpair(leaf_bin, erodedBW, 'montage')

Results - Binarized Image

enter image description here

Result after eroding the image imerode enter image description here

From now on it will be very easy to get the area using contours. Before contour you need to erode it once to remove small artefacts and later dilate it by equal amount. Later find the area.

Good luck :)

$\endgroup$
0
$\begingroup$

Here's my suggestion:

  1. Convert the image to grayscale
  2. Define a threshold and binarize image (only black and white)
  3. To remove the stem apply an erode operator (the size will depend on your image)

Function syntax: https://www.mathworks.com/help/images/ref/imerode.html

  1. apply a dilation operator (same size as in previous step)

Function "imopen" combines both steps: https://www.mathworks.com/help/images/ref/imopen.html

  1. Sum all over the columns (considering that leaf pixels have value 1 and if you are using Matlab colsum=sum(a) )
  2. Sum the previous vector and you will have the area ( area=sum(colsum) )
$\endgroup$
  • $\begingroup$ I followed your steps. The conversion of an image to binary results in both the leaf and its stem portion change to pixels with value 1. Actually, I don't want the stem portion. Any ideas on how to avoid this? $\endgroup$ – user25290 Feb 22 '17 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.