Coloring pixels with a specific color

2 vues (au cours des 30 derniers jours)
Alberto Acri
Alberto Acri le 24 Jan 2023
Commenté : Image Analyst le 26 Jan 2023
Is it possible to create an image (like the original) in which only the desired pixels are colored?
For example, I want to color white only the pixels with the numbers 25 to 27 (present inside 'grayLevel'). Any ideas?
rgb = imread('example.jpg');
%% Matrix of pixels
Number_Of_Rows = height(rgb);
Number_Of_Columns = width(rgb);
grayLevel = zeros(Number_Of_Rows,Number_Of_Columns);
for Row = 1:Number_Of_Rows
for Column = 1:Number_Of_Columns
grayLevel(Row,Column) = rgb(Row, Column);
end
end

Réponse acceptée

Image Analyst
Image Analyst le 24 Jan 2023
You need to somehow get the gray scale image from the RGB image though, maybe like
grayImage = rgb2gray(rgbImage);
Then you can use imoverlay
mask = (grayImage >= 25) & (grayImage <= 27);
rgbImage = imoverlay(grayImage, mask, 'Color', 'w');
  8 commentaires
Alberto Acri
Alberto Acri le 26 Jan 2023
And how can I visualize them? Using for example 'imoverlay'?
Image Analyst
Image Analyst le 26 Jan 2023
No, if you have a gray scale image and you just want white, not a "color", then you don't need imoverlay. You can just use imshow:
imshow(grayImage, []);

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by