我的任務之一是從16000圖像中檢測蟻羣中的某些顏色。所以,我已經用藍色,粉紅色和綠色做得非常好,但現在我需要改進對橙色的檢測。這對我來說有點棘手,因爲我是圖像處理領域的新手。我舉了一些例子,我做了什麼,我的問題是什麼。改善MATLAB中橙色的檢測
的RAW圖像:HTTP://img705.imageshack.us/img705/2257/img4263u.jpg
檢測橙色的:HTTP://img72.imageshack.us/img72/8197/orangedetection。 JPG
檢測綠色的:HTTP:後//img585.imageshack.us/img585/1347/greendetection.jpg
我用了selectPixelsAndGetHSV.m獲得HSV值,並且我用colorDetectHSV .m來檢測具有相同HSV值的像素。 你可以給我任何sugesstion如何改善橙色的檢測,而不是檢測周圍的整個螞蟻和巢?
預先感謝您!
function [K]=colorDetectHSV(RGB, hsvVal, tol)
HSV = rgb2hsv(RGB);
% find the difference between required and real H value:
diffH = abs(HSV(:,:,1) - hsvVal(1));
[M,N,t] = size(RGB);
I1 = zeros(M,N); I2 = zeros(M,N); I3 = zeros(M,N);
T1 = tol(1);
I1(find(diffH < T1)) = 1;
if (length(tol)>1)
% find the difference between required and real S value:
diffS = abs(HSV(:,:,2) - hsvVal(2));
T2 = tol(2);
I2(find(diffS < T2)) = 1;
if (length(tol)>2)
% find the difference between required and real V value:
difV = HSV(:,:,3) - hsvVal(3);
T3 = tol(3);
I3(find(diffS < T3)) = 1;
I = I1.*I2.*I3;
else
I = I1.*I2;
end
else
I = I1;
end
K=~I;
subplot(2,1,1),
figure,imshow(RGB); title('Original Image');
subplot(2,1,2),
figure,imshow(~I,[]); title('Detected Areas');
謝謝你的建議,我嘗試了一些與你的想法結合在一起的東西,它工作。 – 2012-08-07 12:45:00