2

我有:

img = imread('pic.jpg','jpg');
r = img(:,:,1);
g = img(:,:,2);
b = img(:,:,3);

subplot(3,1,1);
imhist(r);
subplot(3,1,2);
imhist(g);
subplot(3,1,3);
imhist(b);

如何将直方图的颜色更改为红色、绿色和蓝色?
如何更改出现的窗口大小?

编辑:
Luis Miguel 关于窗口大小的回答有效,但是如果我只想改变窗口的高度并保持其他参数(x、y、宽度)不变怎么办?

4

2 回答 2

4

窗口大小:
您可以获取然后设置“位置”。

pos = get(h,'Position');
pos(4) = pos(4) + 10; % changing height only
pos(2) = pos(2) - 10; % you probably would want that - just try
set(h, 'Position', pos);
于 2010-10-21T22:56:14.017 回答
2

您可以更改直方图条的颜色及其限制线,如MATLAB 参考中所述,如下所示:

h = findobj(gca,'Type','patch');
set(h,'FaceColor','r','EdgeColor','w')

通过执行以下操作更改窗口大小:

h = figure(1);
set(h, 'Position', [x y width height])
于 2010-10-21T18:55:02.617 回答