【问题标题】:How to correct labeling the detected objects in in a image?如何正确标记图像中检测到的对象?
【发布时间】:2018-03-05 09:30:42
【问题描述】:

我正在尝试确定和计算图像中 WBC 的数量,我可以使用以下代码确定它。但是当我尝试标记检测到的 WBC 时出现,它正在标记圆圈外的数字。结果附在下面。

你能告诉我我在这里缺少什么吗?

clc;
clear all;
close all;

rgb = imread('test.jpg'); 
figure;
imshow(rgb);
binaryImage=im2bw(rgb);
bw = im2bw(rgb, graythresh(rgb));
imshow(bw)
L = bwlabel(bw);
imshow(rgb) hold on

[centers, radii, metric] = imfindcircles(rgb,[9 24],'ObjectPolarity','dark','Sensitivity',0.86,'Method','twostage');

m = viscircles(centers,radii);
[a,b]=size(centers);
disp(a); 
disp(b);
s = regionprops(L, 'Centroid');
for k = 1:numel(s)
  c = s(k).Centroid;
  text(c(1), c(2), sprintf('%d', k), ...
     'Color', 'w', ...
     'HorizontalAlignment', 'center', ...
     'VerticalAlignment', 'middle');
 end
hold off

【问题讨论】:

  • 图片丢失,本页显示一个:en.wikipedia.org/wiki/Westboro_Baptist_Church
  • @YvesDaoust 我猜你是在开玩笑(我笑了),但以防万一,它代表白细胞。
  • 这仍然没有给我们一个图像。
  • 抱歉这个错误。我会尽快更新。再次抱歉。
  • @YvesDaoust 我更新了帖子并添加了图片。再次抱歉

标签: matlab image-processing object-detection


【解决方案1】:

你有点糊涂了。

你的方法是:

1) 计算圆并绘制它们

2) 用完全不同的方法计算圆,并在那里放置标签

使用第一种方法的结果来编写标签不是很有意义吗?你有一行代码说:

[centers, radii, metric] = imfindcircles(rgb,[9 24],'ObjectPolarity','dark','Sensitivity',0.86,'Method','twostage');

请注意,那里写的第一件事是centers,这暗示着这是一个非常适合用于情节中心的东西!

只需删除所有二进制图像内容并编写:

clc;
clear all;
close all;

rgb = imread('https://i.stack.imgur.com/WXpjH.jpg'); 
figure;

imshow(rgb); hold on

[centers, radii, metric] = imfindcircles(rgb,[9 24],'ObjectPolarity','dark','Sensitivity',0.86,'Method','twostage');

m = viscircles(centers,radii);
[a,b]=size(centers);
disp(a); 
disp(b);
% s = regionprops(L, 'Centroid');
for k = 1:size(centers,1)
  c = centers(k,:);
  text(c(1), c(2), sprintf('%d', k), ...
     'Color', 'w', ...
     'HorizontalAlignment', 'center', ...
     'VerticalAlignment', 'middle');
 end
hold off

【讨论】:

  • 非常感谢您的解释,您解决了问题,我现在知道我的错在哪里。它现在工作。再次感谢:)
猜你喜欢
  • 2020-09-21
  • 2019-10-30
  • 1970-01-01
  • 1970-01-01
  • 2020-10-07
  • 2013-01-23
  • 1970-01-01
  • 2012-06-05
相关资源
最近更新 更多