How could I detect color?
조회 수: 1 (최근 30일)
이전 댓글 표시
I used this code to detect the color of circles but the code gives me a wrong color. Could you help me how to fix the mistake here. I think I have something wrong with adjusting the background of the images, but I am not sure.
if true
k = 1 : numberOfBlobs % for each microbeads
tempcolor=round(centroidsAll(k,:));
%cycle 1 color
BackgroundR=mean(mean(CropCycl1Ajust(:,:,1))); BackgroundG=mean(mean(CropCycl1Ajust(:,:,2)));
Cycl1ColorR=mean(mean(CropCycl1Ajust(round(tempcolor(1,1)-radius):round(tempcolor(1,1)+radius),round(tempcolor(1,2)-radius):round(tempcolor(1,2)+radius),1))); %%%Red colors
Cycl1ColorG=mean(mean(CropCycl1Ajust(round(tempcolor(1,1)-radius):round(tempcolor(1,1)+radius),round(tempcolor(1,2)-radius):round(tempcolor(1,2)+radius),2))); %%%Green colors
%set a threshould of 20%. Higher: the color of the microbead
if Cycl1ColorR > BackgroundR*1.2
color(k,1)='Red';
else if Cycl1ColorG > BackgroundG*1.2
color(k,1)='Green';
else
color(k,1)='missing';
end
end
ColorMatrix(k,1)=color(k,1);
end
댓글 수: 2
Image Analyst
2018년 9월 22일
We don't have enough to run your code, like the image or how you segmented the blobs out!
In the meantime, see my color segmentation demos: https://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862&sort=downloads_desc
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Feature Detection and Extraction에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!