Clear Filters
Clear Filters

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

1 view (last 30 days)
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');
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?
  1 Comment
Stelios Fanourakis
Stelios Fanourakis on 26 Apr 2019
Let me know if I have to upload anything such as the image I am trying to crop or the region_seg code.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!