필터 지우기
필터 지우기

May i know how to find for numYellowPixel in this code

조회 수: 2 (최근 30일)
Iszuzuldin amirull bin mohd janudin
편집: Image Analyst 2021년 6월 11일
clc
clear
clear all
images= []
webcamlist()
cam= webcam(1)
preview(cam)
pause(2);
images= snapshot(cam)
imshow(images)
r_channel= images(:,:,1);
g_channel= images(:,:,2);
b_channel= images(:,:,3);
images(:,:,1) =0;
images(:,:,3) = 0;
image(images);
mask= g_channel > 100, b_channel > 800, r_channel < 800, b_channel < 0, r_channel < 0;
numBlackPixels = sum(~mask(:))
gr_ratio = double(g_channel)./double(r_channel);
gb_ratio = double(g_channel)./double(b_channel);
rb_ratio = double(r_channel)./double(b_channel);
% gr_ratio(isnan(g_ratio))=0;
% grayImage = rgb2gray(image);
% binaryImage = grayImage > 20;
% binaryImage = bwareaopen(binaryImage, 50);
% binaryImage = imfill(binaryImage, 'holes');
% grayImage(~binaryImage) = 0;
falseMatrix= zeros(7,7);
targetMatrix= ones(7,7);
checkMatrix= ones(7,7);
fprintf('mask has %d black pixels.\n', numBlackPixels);
if targetMatrix == checkMatrix
% cam = camStop;
return
end
  댓글 수: 2
Jan
Jan 2021년 6월 9일
It is not getting clear to me, what you are asking for.
What is the purpose of this line:
mask= g_channel > 100, b_channel > 800, r_channel < 800, b_channel < 0, r_channel < 0;
Only the first comparison matters, the rest is ignored.
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 6월 9일
Note that "yellow" color pixel is the composition of three layers, viz. Red, Green, Blue. From these three layers in combination, you'd need to create a mask that gives a "Yellow" pixel.

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2021년 6월 10일
Use the ColorThresholder app on the Apps tab of the tool ribbon to create a mask. Then export the function and call it whenever you need to find the yellow mask.
  댓글 수: 2
Iszuzuldin amirull bin mohd janudin
One more questions, how to get pixels of each mango?
Image Analyst
Image Analyst 2021년 6월 11일
편집: Image Analyst 2021년 6월 11일
Exactly what does "get" mean to you. Please be very specific, like locations, colors, both, whatever. Basically use find() and imsplit().
[r,g,b] = imsplit(rgbImage);
[rows, columns] = find(mask); % the BW from the Color Threshold app.
redPixels = r(mask);
greenPixels = g(mask);
bluePixels = b(mask);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by