1506 1

[Weka及其他] MATLAB课程:代码示例之Image Processing and Computer Vision(三) [推广有奖]

企业贵宾

巨擘

0%

还不是VIP/贵宾

-

威望
4
论坛币
624047 个
通用积分
147.0356
学术水平
918 点
热心指数
988 点
信用等级
842 点
经验
398692 点
帖子
9795
精华
48
在线时间
17322 小时
注册时间
2014-8-19
最后登录
2022-11-2

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

MATLAB课程:代码示例之Image Processing and Computer Vision(三)

Detecting a Cell Using Image Segmentation


This example shows how to detect a cell using edge detection and basic morphology. An object can be easily detected in an image if the object has sufficient contrast from the background. In this example, the cells are prostate cancer cells.


Step 1: Read Image

Read in the cell.tif image, which is an image of a prostate cancer cell.

I = imread('cell.tif');figure, imshow(I), title('original image');text(size(I,2),size(I,1)+15, ...    'Image courtesy of Alan Partin', ...    'FontSize',7,'HorizontalAlignment','right');text(size(I,2),size(I,1)+25, ....    'Johns Hopkins University', ...    'FontSize',7,'HorizontalAlignment','right');


Step 2: Detect Entire Cell

Two cells are present in this image, but only one cell can be seen in its entirety. We will detect this cell. Another word for object detection is segmentation. The object to be segmented differs greatly in contrast from the background image. Changes in contrast can be detected by operators that calculate the gradient of an image. The gradient image can be calculated and a threshold can be applied to create a binary mask containing the segmented cell. First, we use edge and the Sobel operator to calculate the threshold value. We then tune the threshold value and use edge again to obtain a binary mask that contains the segmented cell.

[~, threshold] = edge(I, 'sobel');fudgeFactor = .5;BWs = edge(I,'sobel', threshold * fudgeFactor);figure, imshow(BWs), title('binary gradient mask');


Step 3: Dilate the Image

The binary gradient mask shows lines of high contrast in the image. These lines do not quite delineate the outline of the object of interest. Compared to the original image, you can see gaps in the lines surrounding the object in the gradient mask. These linear gaps will disappear if the Sobel image is dilated using linear structuring elements, which we can create with the strel function.

se90 = strel('line', 3, 90);se0 = strel('line', 3, 0);


The binary gradient mask is dilated using the vertical structuring element followed by the horizontal structuring element. The imdilate function dilates the image.

BWsdil = imdilate(BWs, [se90 se0]);figure, imshow(BWsdil), title('dilated gradient mask');


Step 4: Fill Interior Gaps

The dilated gradient mask shows the outline of the cell quite nicely, but there are still holes in the interior of the cell. To fill these holes we use the imfill function.

BWdfill = imfill(BWsdil, 'holes');figure, imshow(BWdfill);title('binary image with filled holes');


Step 5: Remove Connected Objects on Border

The cell of interest has been successfully segmented, but it is not the only object that has been found. Any objects that are connected to the border of the image can be removed using the imclearborder function. The connectivity in the imclearborder function was set to 4 to remove diagonal connections.

BWnobord = imclearborder(BWdfill, 4);figure, imshow(BWnobord), title('cleared border image');


Step 6: Smoothen the Object

Finally, in order to make the segmented object look natural, we smoothen the object by eroding the image twice with a diamond structuring element. We create the diamond structuring element using the strel function.

seD = strel('diamond',1);BWfinal = imerode(BWnobord,seD);BWfinal = imerode(BWfinal,seD);figure, imshow(BWfinal), title('segmented image');


An alternate method for displaying the segmented object would be to place an outline around the segmented cell. The outline is created by the bwperim function.

BWoutline = bwperim(BWfinal);Segout = I;Segout(BWoutline) = 255;figure, imshow(Segout), title('outlined original image');




二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Processing processI Computer MATLAB课程 compute MATLAB课程 代码示例 ImageProcessingandComputerVision DetectingaCellUsingImageSegmentation

本帖被以下文库推荐


https://www.cda.cn/?seo-luntan
高薪就业·数据科学人才·16年教育品牌
沙发
Aloha遇见你 在职认证  发表于 2016-3-14 12:01:19 |只看作者 |坛友微信交流群
很赞,有用!!

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-28 07:37