Let me know if I have to upload anything such as the image I am trying to crop or the region_seg code.
Why region_seg_demo is not working for the imcrop size of my preference?
1 次查看(过去 30 天)
显示 更早的评论
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
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Vehicle Scenarios 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!