Why region_seg_demo is not working for the imcrop size of my preference?

1 visualizzazione (ultimi 30 giorni)
Hi
I use the below code I found in the Mathworks community
S = uigetfile('*');
Img= imread(S);
Img = double(Img(:,:,1));
Img = imcrop(Img,[253.25 158.25 447 132]);
I = Img;
m = zeros(size(I,1),size(I,2)); %-- create initial mask
m(5:80,80:550) = 1;
I = imresize(I,.5); %-- make image smaller
m = imresize(m,.5); % for fast computation
subplot(2,2,1); imshow(I); title('Input Image');
subplot(2,2,2); imshow(m); title('Initialization');
subplot(2,2,3); title('Segmentation');
figure
seg = region_seg(I, m, 3000); %-- Run segmentation
subplot(2,2,4); imshow(seg); title('Global Region-Based Segmentation');
And I get the below error when I choose my preffered cropping size window
Index exceeds the number of array elements (15008).
Error in region_seg (line 51)
u = sum(I(upts))/(length(upts)+eps); % interior mean
Error in region_seg_demo (line 30)
seg = region_seg(I, m, 3000); %-- Run segmentation
Any idea the cause of this error?
Thanks

Risposte (0)

Categorie

Scopri di più su Vehicle Scenarios in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by