How to segment a region

5 views (last 30 days)
Warid Islam
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');

Accepted Answer

Image Analyst
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);
  1 Comment
Warid Islam
Warid Islam on 11 Jul 2019
Hi,
That works perfect. Thanks a lot.

Sign in to comment.

More Answers (0)

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!