-3

I have my histogram with this appearance

enter image description here

And he wanted to get this way, but I don't know which fields should I change or where

I wanted to like this

enter image description here

How can i make this definition?

Benoit_11
  • 13,905
  • 2
  • 24
  • 35
lion
  • 11
  • 1

1 Answers1

0

I understand you want to plot the histogram of an image in a way to limit the x axis to 255 shades of gray and y to the number of pixels in the image. This should do the work:

ima=[1 2 255;0 23 78;3 60 200;255 0 78]
plot([0:255],hist(ima(:),[0:255]))
set(gca,'xLim',[0 255])
set(gca,'yLim',[0 numel(ima)])
Lord Henry Wotton
  • 1,332
  • 1
  • 10
  • 11
  • You would replace the whole `calcHistogram` function body with what I posted, but you would have to delete the first line of my post (because I'm creating a toy image called `ima`) and change argument `image` to `ima`. – Lord Henry Wotton Jan 03 '15 at 00:45
  • What is the size of `image`? Another thing, please avoid using the name `image` since there is a Matlab function with that name. Use `ima` instead, or some other name. – Lord Henry Wotton Jan 03 '15 at 00:57
  • Your image is and RGB image, not grayscale, that is why it is not working. Your question does not have that clear, and apparently you don't understand the difference. You would need either to create a one histogram per channel R, G, B or to convert the image to grayscale and compute the histogram with the code I posted earlier. If you want to change the granularity of the axis, you would have to set the properties `XTick` and `YTick` of the figure's axis. – Lord Henry Wotton Jan 03 '15 at 01:07
  • Ok, its true, but how can i make a color histogram? – lion Jan 03 '15 at 01:23
  • You can't, you would have to create three histograms, one per channel. For example, `r=ima(:,:,1)` would be the red channel. Green and blue would be obtained by replacing 1 with 2 and 3, respectively. – Lord Henry Wotton Jan 03 '15 at 01:38
  • Ok, I'll try. One more question, and I apologize to bother him. I have an edit text, an OK button and a slider. Want when you enter a value in the edit text and press ok, this value pass to the slider, and this value is the degree of rotation of an image, can you help me? I've tried and I'm not getting through values. – lion Jan 03 '15 at 01:43
  • 1
    Look buttons and sliders are the subject of another question. I recommend you to look at guidelines on how to ask questions on SO. Also, if you agree that my answer to the question solves the **original problem** you posted, make sure to mark it as answered so others that look for a similar solution will attempt the code. Good luck! – Lord Henry Wotton Jan 03 '15 at 02:50