How to segment a region

5 次查看(过去 30 天)
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');

采纳的回答

Image Analyst
Image Analyst 2019-7-10
Try this
hFig = figure;
subplot(1, 2, 1);
rgbImage = imread('Intensity1.jpg');
imshow(rgbImage)
subplot(1, 2, 2);
croppedImage = rgbImage(200 : 400, :, :);
imshow(croppedImage);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Geometric Transformation and Image Registration 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by