How to segment a region
5 views (last 30 days)
Show older comments
Warid Islam
on 10 Jul 2019
Commented: Warid Islam
on 11 Jul 2019
I have an image from which I want to extract a region and display it in a separate image . I have written a code but it's displaying an error message.
Below is my code:
I = imread('Intensity1.jpg');
imshow(I)
hold on
mask = false(size(I));
mask(200:400) = true;
visboundaries(mask,'Color','b');
I want to extract the region from 200:400(i.e. only the yellow and green part of the image) and display them separately . But I am shown the following error message:
Error using visboundaries
Expected input number 1, BW, to be two-dimensional.
Error in visboundaries>obtainAndValidateBoundaries (line 236)
validateattributes(B, {'numeric','logical'}, {'2d','real','nonsparse'}, ...
Error in visboundaries>parseInputs (line 185)
boundaries = obtainAndValidateBoundaries(B,first_string);
Error in visboundaries (line 91)
[ax, boundaries, options] = parseInputs(varargin{:});
Error in I2 (line 7)
visboundaries(mask,'Color','b');
0 Comments
Accepted Answer
Image Analyst
on 10 Jul 2019
Try this
hFig = figure;
subplot(1, 2, 1);
rgbImage = imread('Intensity1.jpg');
imshow(rgbImage)
subplot(1, 2, 2);
croppedImage = rgbImage(200 : 400, :, :);
imshow(croppedImage);
More Answers (0)
See Also
Categories
Find more on Geometric Transformation and Image Registration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!