Why do I get error using graph cut method for segmentation?

I generated a segmentImage(RGB) function by choosing my desired foreground and background region using graph cut method. This function is working well with the original image I used to create the function. However, when I use this segmentImage(RGB) function to perform the same segmentation on another image, I get the following error message:
1)Error using lazysnapping>getIndices (line 297) Linear indices cannot exceed the number of elements in the label matrix.
2)Error in lazysnapping>validateInputs (line 258) foregroundInd = getIndices(foreground, size(L));
3)Error in lazysnapping (line 160) [foregroundInd,backgroundInd,is3D] = validateInputs(A,L,foreground,background);
4)Error in ImageAnalysis_v04_GraphCut>segmentImage_g (line 125) BW = lazysnapping(scaledX,L2,foregroundInd,backgroundInd);
5)Error in ImageAnalysis_v04_GraphCut (line 11) [g_BW,g_maskedImage] = segmentImage_g(i);

1 Comment

I don't know. What do you think you can you do to help us help you?
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
And don't use i for the name of your image. It's the imaginary variable. Call it grayImage or something descriptive.

Sign in to comment.

Answers (0)

Asked:

on 26 Dec 2022

Commented:

on 26 Dec 2022

Community Treasure Hunt

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

Start Hunting!