簡體   English   中英

如何正確標記圖像中檢測到的物體?

[英]How to correct labeling the detected objects in in a image?

我嘗試確定並計算圖像中的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

你有點困惑。

您的方法是:

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

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM