How to convrt parts of grayscale to RGB

4 visualizaciones (últimos 30 días)
Yubin ZHONG
Yubin ZHONG el 6 de Nov. de 2019
Comentada: ME el 7 de Nov. de 2019
It's not simply convert a whole figure.
I just want to use a simple methods to finish a line trace. Like mark the air flow on a photo of wind tunnel experiment
The idea is convert the photo to grayscale first
Then check the grayscale of each pixel in a specific area
If the grascale is in a specific range (eg: 210 to 230)
Then convert it to red or blue
So that the air flow will be some colorful line on a grarscale figure.
But I don't know hot to check the pixel and convert them.

Respuesta aceptada

ME
ME el 6 de Nov. de 2019
This should do the trick:
A = rgb2gray(imread('image.png'));
A = cat(3, A, A, A);
s=size(A);
for i=1:s(1)
for j=1:s(2)
if(A(i,j,1)<=230 && A(i,j,1)>=210)
A(i,j,1:3) = [255 0 0];
end
end
end
It will convert any grayscale sections in the range 210 to 230 to red. You could also add another similar if statement if you wanted to also add an additional condition to make some of it blue.
  4 comentarios
Yubin ZHONG
Yubin ZHONG el 7 de Nov. de 2019
Oh my first time use mathwork,,,, didnt notice that
ME
ME el 7 de Nov. de 2019
No problem at all. Thanks for accepting my answer and I’m glad I could help.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by