matlab中如何给特定区域填充色彩?

2024-11-14 14:57:33
推荐回答(3个)
回答1:

使用fill函数,具体的方法是
fill(x,y,c)
其中区域是使用x和y来指定,c来指定颜色
例如fill([0 1 1 0],[0 0 1 1],'r')是给一个矩形区域填充红色

FILL(X,Y,C) fills the 2-D polygon defined by vectors X and Y
with the color specified by C. The vertices of the polygon
are specified by pairs of components of X and Y. If necessary,
the polygon is closed by connecting the last vertex to the first.

If C is a single character string chosen from the list 'r','g','b',
'c','m','y','w','k', or an RGB row vector triple, [r g b], the
polygon is filled with the constant specified color.

祝你学习愉快!

回答2:

使用fill函数,具体的方法是:
fill(x,y,c)。
其中区域是使用x和y来指定,c来指定颜色。
例如fill([0 1 1 0],[0 0 1 1],'r')是给一个矩形区域填充红色。
FILL(X,Y,C) fills the 2-D polygon defined by vectors X and Y with the color specified by C. The vertices of the polygon are specified by pairs of components of X and Y. If necessary,
the polygon is closed by connecting the last vertex to the first.
If C is a single character string chosen from the list 'r','g','b',
'c','m','y','w','k', or an RGB row vector triple, [r g b], the polygon is filled with the constant specified color.

回答3:

把每个像素按照rgb分量分别赋值,最后用imshow显示图像即可