I get two different plots using matlab 2013 and octave 4.0 see code below is there anyway to show the different colors in the plot like matlab shows using octave? Input image of marbles.jpg: http://i.imgur.com/17S9PUK.jpg pkg load image rgbImage = imread('/tmp/marbles.jpg');); % Load image Image of marbles.jpg: http://i.imgur.com/17S9PUK.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 hBar = bar(binEdges(1:end-1),N(1:end-1),'histc'); %# Plot the histogram set(hBar,'CData',1:360,... %# Change the color of the bars using 'CDataMapping','direct',... %# indexed color mapping (360 colors) 'EdgeColor','none'); %# and remove edge coloring colormap(hsv(360)); %# Change to an HSV color map with 360 points 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 Matlab 2013 what the Plot looks like https://i.stack.imgur.com/mHIoc.png But when I create the plot with Octave 4.0 I get http://i.imgur.com/acubTY9.png The main goal is to have the histogram colors be the same as the matlab plot. How can I fix this? _______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave |
On Apr 23, 2017 9:56 AM, "RT" <[hidden email]> wrote:
don't have either in front of me to test, but can you step through and find the first point where things differ between the two? My guess is its something with colormap, but it could be at the set command or an incompatibility with one of those options, or on one of the redraws with the later commands, etc. nickj _______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave |
In reply to this post by RT
The CData property doesn't seem to be implemented in the Octave version of the bar command.
You could work around this by plotting all the single bars individually. And setting an individualy color of each individual bar. The following code runs for several seconds, but works generally fine for me (in Octave 4.2.1): --- code ---- pkg load image rgbImage = imread('marbles.jpg'); % Load image Image of marbles.jpg: http://i.imgur.com/17S9PUK.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 = 10; % 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 --- code --- By the way, Matlab seems to also have the same problems, when using a Matlab version of 2014b or newer, see [1] I hope this helps. Hartmut [1] https://de.mathworks.com/matlabcentral/answers/99092-how-do-i-define-colors-for-individual-bars-on-my-bar-graph-according-to-their-values-in-matlab |
In reply to this post by NJank
How would I step through plotting different colors? It either plots a color or it doesn't. Am I missing something? Thanks On Sun, Apr 23, 2017 at 2:35 PM, Nicholas Jankowski <[hidden email]> wrote:
_______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave |
Free forum by Nabble | Edit this page |