2010-10-21 95 views
2

我:MATLAB:如何改變imhist的顏色和窗口大小?

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); 

我如何改變柱狀圖的顏色以紅,綠,藍?
如何更改出現的窗口大小?

編輯:
路易斯·馬吉爾的有關窗口作品尺寸的答案,但如果我想只改變窗口的高度,離開其他parameneters(X,Y,寬度)不變的是什麼?

+0

你可以找到這個答案的相關有色這個柱狀圖的例子:http://stackoverflow.com/questions/3961971/how-do-i-re-implement-a-color-based-histogram- do-feature-extraction-based-col/3962867#3962867 – Amro 2010-10-21 19:58:51

+0

這很好,但我必須使用imhist。 – 2010-10-21 22:32:34

+0

我剛剛意識到這是你的問題,對不起;) – Amro 2010-10-21 23:24:42

回答

4

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

要通過做這樣的事情改變窗口大小窗口大小:
您可以獲取並設置'位置'。

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); 
+3

你可以做'pos(2)= max(pos(2)-10,0);'以防止窗口底部離開屏幕。 – yuk 2010-10-21 23:54:37

2

可以更改柱狀圖和他們的極限線的顏色爲MATLAB's reference提到的,像這樣:

h = figure(1); 
set(h, 'Position', [x y width height]) 
+0

你可以混合這與我的代碼?我不知道該怎麼做... – 2010-10-21 18:58:00

+0

它不適用於imhist。它適用於hist。我怎樣才能做到這一點? – 2010-10-21 19:27:09

+0

您可以在實際繪製之前嘗試設置圖形的大小。那麼當你繪製它時會佔據數字窗口,我想。 – 2010-10-22 01:43:36