how to access rgb spectrum through array
5 views (last 30 days)
Image Analyst on 8 Dec 2022
You should really use the Color Thresholder app on the Apps tab of the tool ribbon. Set your thresholds there and then use the button to export the code.
Your thresholds are not in the range for HSV images (0-100 for V, 0-1 for H and S). They're more in the range like youi'd use for RGB thresholding. They look like they will threshold for cyan color, not yellow. Here is the code:
rgbImage = imread("practice2.jpeg");
[rows, columns, numberOfColorChannels]=size(rgbImage);
% Define mask to find cyan (not yellow).
yellow_low = ([20,100,100]);
yellow_high = ([30,255,255]);
[r, g, b] = imsplit(rgbImage);
mask = (yellow_low(1) < r & r < yellow_high(1)) &...
(yellow_low(2) < g & g < yellow_high(2)) & ...
(yellow_low(3) < b & b < yellow_high(3));
subplot(2, 1, 1);
subplot(2, 1, 2);
Since there is no cyan in your image, the mask shows nothing.
Why did your code throw an error? Because you used size wrong and forgot to include the third output argument.
See Steve's blog for an explanation: