How do I perform Image segmentation in an RGB image using pattern?

I want to create 2 segment in the attached RGB interference image. 1 segment would be the horseshoe pattern as can be observed in the image and the other segment would be rest of the image. So far I have tried: Edge detection using Canny, Kmeans cluster, imsegkmeans.
The clustering is almost working, but I get cluster within a cluster due to the RGB values. I want to avoid that and have just two segments from the image.

 Accepted Answer

load Image
[r,g,b]=imsplit(I);
lev=multithresh(r,2);
L=imquantize(r,lev);
H=bwareafilt( imfill(L==2,'holes') ,1) ;
BG= L>1 & ~H;
L=H+2*BG;
immontage({I,L})

More Answers (1)

You are pretty much doomed to failure if you want to segment the horseshoe pattern from the rest of the image. The rest of the image includes the black background, which will have such great differences in characteristics from the circle that any method you use for segmenting into exactly two regions is very likely to pick out the black background as one region and the entire circle as the second region.

1 Comment

Thank you for your response. i cropped the original image that had fringes. Do you suggest I use the original image for this?

Sign in to comment.

Products

Release

R2023a

Asked:

on 16 Mar 2026 at 15:54

Commented:

on 17 Mar 2026 at 12:40

Community Treasure Hunt

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

Start Hunting!