1

I have an image and I have extracted rgb values of a particular region and stored it on a text file (See Text File)

To read R values :

fid = fopen('input.txt');
R = textscan(fid, '%f %*[^\n]');
R = C{:};
fclose(fid);

Similarly I can read other values and store it in G & B

But how can I plot all of them on same histogram. I need them together so I can calculate maximum likelihood estimator from histogram.

Thanks for Helping.

  • Just a friendly tip, you may want to read over this page: [How-To-Ask Guide](https://stackoverflow.com/help/how-to-ask) so you can always be sure that your questions are easily answerable and as clear as possible. Be sure to include any efforts you've made to fix the problem you're having, and what happened when you attempted those fixes. Also don't forget to your code and any error messages! – Matt C Apr 03 '16 at 04:02

1 Answers1

0
x=dlmread('filename',' ')
hist(x)

also check

bar3(x)

You won't be able to plot a multivariate histogram as that'd be a 4D plot.

To build your 3D bins, you can make something like:

s=32;%bin separation (power of 2)

r=[0:s:255]

bins=combvec(r,r,r)+s/2 %your bins, size is (256/s)^3    
binval=zeros(length(grid),1)

x=dlmread('filename',' ')
for m = [ 1:length(x)]
  for n = [ 1:length(bins)]
%using infinite norm, note bin off-centering
    if norm(x(m,:)-(grid(n,:)-0.5),inf) < s/2
       binval(n)+=1
       break
    end
  end
end

If you still want a 4D histogram plot, try using scatter3 . Use binval for the marker size and even C. for the RGB colour.

xvan
  • 4,554
  • 1
  • 22
  • 37