Gnoivce와 Hartmut은이 코드로 많은 도움을 주었지만 실행하는 데 시간이 오래 걸립니다. bar 명령의 CData 속성이을 사용하는 Octave 4.0-4.2.1 버전에서 구현되지 않은 것 같습니다. 이를 해결하기 위해 모든 단일 막대를 개별적으로 플롯하고 각 막대마다 개별 색상을 설정했습니다. 사람들은 나를 도왔고 지금까지 나를 잡았습니다. 5 분 플롯을 보여줄 사람이 누구보다 빨리 속도를 낼 수 있을까요?Octave/Matlab 플롯 가속화
clear all,clf reset,tic,clc
rgbImage = imread('/tmp/marbles.jpg');
hsvImage = rgb2hsv(rgbImage); % Convert the image to HSV space
hPlane = 360.*hsvImage(:, :, 1); % Get the hue plane scaled from 0 to 360
binEdges = 0:360; %# Edges of histogram bins
N = histc(hPlane(:),binEdges); %# Bin the pixel hues from above
C = colormap(hsv(360)); %# create an HSV color map with 360 points
stepsize = 1; % stepsize 1 runs for a while...
for n=binEdges(2:stepsize:end) %# Plot the histogram, one bar each
if (n==1), hold on, end
h=bar(n,N(n));
set(h,'FaceColor',C(n,:)); %# set the bar color individually
end
axis([0 360 0 max(N)]); %# Change the axes limits
set(gca,'Color','k'); %# Change the axes background color
set(gcf,'Pos',[50 400 560 200]); %# Change the figure size
xlabel('HSV hue (in degrees)'); %# Add an x label
ylabel('Bin counts'); %# Add a y label
fprintf('\nfinally Done-elapsed time -%4.4fsec- or -%4.4fmins- or -%4.4fhours-\n',toc,toc/60,toc/3600);
플롯은 5 분 후에 생성 : marbles.jpg 이미지 파일은 아래 사용
코드의 어느 부분이 오래 걸리는지 확인해 봤습니까? 그것은 루프인가? – gnovice
@gnovice 네,'stepsize = 1; % stepsize 1이 잠시 동안 실행됩니다.'stepsize가 10으로 설정되면 시간이 증가하게됩니다. '더 빠르지 만 막대 사이에 빈 공간이 남습니다. –
바 플롯 대신 이미지를 생성하지 않는 이유는 무엇입니까? – Andy