How to segment this image better?

1 view (last 30 days)
Tao Hu
Tao Hu on 18 May 2023
Commented: Image Analyst on 23 May 2023
I'm tring to segment the below image using imsegkmeans. The objective is to segment the leaves from the background. Some dark part and yellow part are misclassified. Could anyone point some directions for me to improve the results? Really appreciate it! Below are the original image and the results.

Answers (2)

Vinayak
Vinayak on 22 May 2023
To improve the segmentation results of leaves from the background using imsegkmeans, you can try implementing the following,
  1. Adjust the number of clusters: imsegkmeans requires the number of clusters to be specified. You can try adjusting this parameter to see if it improves the segmentation. For example, you can try reducing the number of clusters to segment the leaves from the background more accurately. More information about this method can be inferred from here https://www.mathworks.com/help/images/ref/imsegkmeans.html#d124e195494
  2. Preprocessing: Prior to segmentation, you can preprocess the image to improve the results. For example, you can apply noise reduction filters like Median filter or Gaussian filter to remove noise from the image.
  3. you can try combining imsegkmeans with other segmentation methods like active contours or thresholding to improve the results.
  4. Post-processing: After segmentation, you can perform post-processing to refine the segmentation results. For example, you can fill the holes in the segmented regions using morphological operations like imfill and imopen.
  2 Comments
Tao Hu
Tao Hu on 23 May 2023
Thank you. I got the above result with the number of clusters set to 2. The main problem is that dark colors are classified as background. There are very limited paramerters to be tuned with imsegkmeans
Image Analyst
Image Analyst on 23 May 2023
Right. Your image is bad. Did you see my Answer below? Please fix your image capture conditions and repost your improved images.

Sign in to comment.


Image Analyst
Image Analyst on 22 May 2023
The two main problems in the image are poor lighting and lens shading. Try to put the paper in a light booth where the lighting is uniform and you'll have no shadows. It should be like an integrating sphere, in other words, a box with lighting from above with the insides of the booth painted white or gray. If you still can't get rid of the shadows, then add some led light bars down low.
It also looks like you have a really bad lens because you have severe lens shading. The center is much, much brighter than the edges. You need to do a background correction where you divide your image by the percentage of light at each pixel location. This will "flatten" the image and undo the effects of lens shading and allow for much better segmentation, perhaps even with a simple global threshold. I'm attaching a background correction demo.

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!