- Converting the Image to HSV color space uning 'rgb2hsv' function.
- Define color specific thresholdsholds.
- Color thresholding can be done using ‘Color Thresholder app’ or writing custom code.
- Apply the mask to the original image and extract specific colors using 'bsxfun' function.
Image processing image color
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Làm thế nào tôi có thể phát hiện đối tượng màu (đỏ xanh lục) trong ảnh cùng lúc bằng không gian HSV.
Cảm ơn bạn.
0 Kommentare
Antworten (1)
Rahul
am 14 Nov. 2024 um 5:52
In order to detect colored objects from like the red and green objects from the provided figure using the HSV color space the following steps can be considered:
Here is an example:
% Using 'rgb2hsv' to convert the image to HSV color space
hsvImage = rgb2hsv(image);
% Creating masks based on threshold values (Can be adjusted accordingly to requirement)
redMask = ((hsvImage(:,:,1) >= 0) & (hsvImage(:,:,1) <= 0.1) | (hsvImage(:,:,1) >= 0.9) & (hsvImage(:,:,1) <= 1)) & (hsvImage(:,:,2) >= 0.5) & (hsvImage(:,:,3) >= 0.5);
greenMask = (hsvImage(:,:,1) >= 0.25) & (hsvImage(:,:,1) <= 0.45) & (hsvImage(:,:,2) >= 0.5) & (hsvImage(:,:,3) >= 0.5);
combinedMask = redMask | greenMask;
% Applying the mask to the original image using 'bsxfun' function
outputImage = bsxfun(@times, image, cast(combinedMask, 'like', image));
imshow(outputImage);
Here is what the 'outputImage' looks like:
Refer to the following MathWorks documentations to know more:
'Color Thresholder App': https://www.mathworks.com/help/releases/R2020a/images/ref/colorthresholder-app.html
Thanks.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!