Steve on Image Processing with MATLAB

Image processing concepts, algorithms, and MATLAB

Note

Steve on Image Processing with MATLAB has been archived and will not be updated.

bwselect

Didja know about the Image Processing Toolbox function bwselect?

For a blog post I wrote earlier this month, I wanted a binary image containing only the central blob indicated in red below:

url = 'https://blogs.mathworks.com/images/steve/163/plateaus.png';
bw = imread(url);
imshow(bw)
annotation(gcf,'ellipse','LineWidth',3,...
    'Position',[0.4931 0.463 0.07575 0.2029],...
    'Color',[0.8471 0.1608 0]);

The Image Processing Toolbox function bwselect is perfect for this task. You can use it interactively or noninteractively.

If you use the interactive syntax:

 bw2 = bwselect(bw)

the function displays bw and waits for you to click on the image with the mouse. You can click on one or multiple points. To finish your selection, double-click on the last point, or just press RETURN. bwselect then returns a binary image containing only the objects ("blobs") that you clicked on.

You can also use the noninteractive syntax, in which you pass in the point locations as input arguments instead of using the mouse.

For example:

pond = bwselect(bw, 183, 170);
clf
imshow(pond)

I hope you find this function useful.




Published with MATLAB® 7.5

|
  • print

댓글

댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.