0

I'm working with leaves' images in matlab. I will compare portions of those leaves through some similarity functions (euclidean for example), but first I need to extract portions of each leave and then save them. So, this is my problem now: how do I select those portions and draw a rectangle that shows me what will be cut? I already got the centroid and a boundingBox by using regionprops function (you can see those in red in the image firstResultsMatlab.png). However, I'm struggling by trying to draw and extract portions like those that are in blue (same image). I don't want to get parts from the black background, only portions from the leave.

I've also added an images of leaf as an example of what I've been working on and the code I used to get a boundingBox and the centroid. Any ideas are welcomed!

Thank you very much in advance.

I = imread('C:\Users\IBM_ADMIN\Desktop\Mestrado\Imagens_Final\IMG1_N1_1.png');
L = bwlabel(I);

s = regionprops(L,'BoundingBox');
stat = regionprops(L,'centroid');

hold on;
colors = hsv(numel(s)); 
for k = 1:numel(s) 

him = imshow(I); 
hold on; 
rectangle('Position', s(k).BoundingBox, 'EdgeColor', colors(k,:));
plot(stat(k).Centroid(1),stat(k).Centroid(2),'rx');
end

matlab-results leaf-1

  • Just to be sure... do you want portions from the leaf or the entire contour of leaf (as if you have cut it by scissor)? If you just want the portion, exactly as shown by blue boxes, then why don't you take a random box and check if it contains a cluster of black pixels, if yes discard it. If you want the contour, then segmentation is the way to go and its a little bit harder than the previous case. However, you can start with watershed segmentation. – Autonomous May 17 '16 at 03:16
  • Hi, Parag. First of all, thank you for your ideas =) I just need portions (as the blue boxes show) and all of them in the same size. I had to think in this solution (instead of the entire leaf) because each leaf has a different size, and if I get the leaf I will have problems to compare matrixes with different sizes. Thank you! – Queila Martins May 17 '16 at 13:03
  • so did my solution solve your problems? – Autonomous May 18 '16 at 03:10
  • 1
    I'd say yes, as yesterday I tried something similar and it worked: using the centroid I got a big box as a big portion of the image. Now I need to work on a way to get those 4 portions separated, and then I will try to check those clusters of black pixels you suggested. Thank you so much! – Queila Martins May 18 '16 at 19:25

0 Answers0