How to convrt parts of grayscale to RGB
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
ME
2019-11-6
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!