필터 지우기
필터 지우기

General leaf segmentation for white or colored background

조회 수: 2 (최근 30일)
Queila Martins
Queila Martins 2015년 10월 16일
답변: waqar ismail 2018년 2월 4일
Hi,
I need to do an image segmentation on a leaf image. My image dataset has 2 types of images: some have white background and some have blue background. User "Image Analyst" here in Mathworks helped me to get the perfect result for images that have a blue background, but I don't get the right results for images that have a white background. So, what should I change to get this code to work in any background images (colored or white)?. I'm sorry for asking here again (I guess this must be simple), but I'm new at matlab programming and I couldn't develop a good solution by myself yet.
I'm providing the code I've been using for blue background images. Also, I'm adding two images samples I need to segment: one is a blue background imagne and the other is a white background image (I want only the leaf mask, that's why the new background must be black).
Thank you in advance!

채택된 답변

Image Analyst
Image Analyst 2015년 10월 16일
You just need to look at the histogram and realize what they're telling you. You see one hump that is brighter than 230 and that is obviously the bright background, and one hump less than 230 and that is obviously the dark leaf. So you just change this line of code:
leafMask = redChannel < 230 & greenChannel < 230 & blueChannel < 230;
Or, you could actually get away with just one channel since the background is so much brighter than the leaf in every channel:
leafMask = blueChannel < 230;
You could do both images in one shot if you have:
leafMask = redChannel < 230 & greenChannel < 230 & blueChannel < 230 & ...
redChannel > 50 & greenChannel > 50;
  댓글 수: 2
Image Analyst
Image Analyst 2015년 10월 16일
You might also segment the leaf by hue in HSV color space. See the HSV color segmentation demo in my File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
Queila Martins
Queila Martins 2015년 10월 16일
Image Analyst, thank you SO much for your explanation again. I really need to study more about histograms and matlab in general.
Also, I had already seen your HSV tutorial and it's great!
If there is a way I can use your name as a reference for my Master's project, please let me know. I'll do it for sure.
Thank you very much again!
Queila

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

waqar ismail
waqar ismail 2018년 2월 4일
i need dataset and segmentation code that u use. it is part of my project..please mail me at

Community Treasure Hunt

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

Start Hunting!

Translated by