# Matlab Image Processing Tutorial includes histograms and imhist well welcome down some Griffins Fort MATLAB tutorial this is mainly concerned with point processing and image processing in MATLAB as before and present working directory still called a MATLAB and we have a number of images here and we're going to be looking at Sorento so we're going to read in our very first image and the command to read in an image is so and I'm not going to suppress the output just for the moment and MATLAB is case sensitive so I've got to do this and a lot of numbers are going to flash by here so what's going on and let's do my so it's 960 be 1280 by 3 a red plane a green plane and a blue plane if I say this so the red is 18 the green is territory and the blue is 38 so those added together would give you a fairly dark color black if we go somewhere else completely in the image no idea what it's going to be like so the red is 1/2 H the green is 1 4 7 and the blue is 1/6 you so they'll give us something like a midwife ok so what does th look like so there we are a pretty picture of Sorrento okay now what's this so we know number way to get in size the image we mentioned this already then tell me that we can say this okay same information just give me a different way I got to convert a to grayscale okay gray let's have a look so there is in greyscale and now I'm going to look at the histogram of that it's okay now we showed through together in a minute but for the moment zero is black 255 white and up here is the count so you can see here that we have 3 by 10 to the 4 that's over 30 thousand pixels our white are 250 and we can see here that we have 1 by 10 to 4 that's 10,000 so we have 10,000 pixels for all of i/os a rough between 30 and 150 very roughly like that very few black and very few pixels around the 200 area can we see the two of them lined up together yes we can we can say subplot so let's get out a sub plus one comma two come on we created two placeholders and the first one we've put in the first time we've put in a gray and now I'm in the right hand side I'm going to show histogram values like so and there we are so what's going on here hopefully you can see this we can see here that there are loads of darkest to mid gray so that's their the headland and some of the dark water here these very high values over here are the sky which is near white and the very bright bits the sea and then there's really no black if we just say these darkest values around 30 will correspond to just where the mouse is pointing at the moment so the next command I want to talk to you about is ima just and that does a contrast stretch so if I say a B equals I am I just semicolon now let's look at two histograms well let's look at that image now start so that's it didn't naked-eye not much might have happened it might look like the same let's put the two histograms up by each other out by side-by-side so now we're going to put that first so if you remember this is the original histogram before we did the contrast stretch and now on this side we're going to put the contrast stretched so what's going on here you can see here that in the one that's the original here on the left very few black pixels on the right that we've got we've stretched as we've dragged some pit there is black so in effect that you've got your rubber band allegiant and you've talked it to the limit of 0 and 255 the naked eye might nip to- might appear that much different both you should get more of a dynamic range with the contrast stretched image and the next command I want to talk to you about is I am to be W and that's going to convert the grayscale image to black and white so we say C equals I M to be W and we're going to take the original on contrast switched image so that's current convert the grayscale image to black and white let's have a look and sorry about that let's just one more Goa and there it is it's a black-and-white image so it MATLAB is clicked on a threshold image which are shown valuations he just say for sake of argument 100 so any pixels are in the range of North to 99 become black so that'll be along there and any pixels that are a hundred or more become white so we end up with that okay that concludes our very basic introduction thank you

### 26 thoughts on “Matlab Image Processing Tutorial includes histograms and imhist”

• June 5, 2019 at 3:32 pm

sei un bombone

• June 5, 2019 at 3:32 pm

In the histogram what is that y axis exactly means ?

• June 5, 2019 at 3:32 pm

Hello sir, can you please suggest me how to get slice corresponds to each histogram elements?

• June 5, 2019 at 3:32 pm

• June 5, 2019 at 3:32 pm

imagerie médical donner moi un exemple svp

• June 5, 2019 at 3:32 pm

is it same to use with matlab r2009a

• June 5, 2019 at 3:32 pm

it's possible to get an histogram from a cropped part of an image, using the command 'imcrop'?

• June 5, 2019 at 3:32 pm

nice explaination, is it suitable for camera captured document..???

• June 5, 2019 at 3:32 pm

hi robert. can you email at my work address please. sorry for delay in gettig back

• June 5, 2019 at 3:32 pm

hi there anselm, this video is really useful. However, I am facing problems with the uint8 problem whereby it doesn't allow me to execute the command of 'imshow(a)' and how you get the image of different class?

• June 5, 2019 at 3:32 pm

Hello Anselm, i have some greyscale images and i would like matlab to transform them back to RGB. Is there a way you can give me some information on how to do this please?

• June 5, 2019 at 3:32 pm

its really nice explanation but which surprised me that i could not see the histogram in RGB COLOR , WHY ?

When i convert it to gray i study the histogram >>

• June 5, 2019 at 3:32 pm

rgb2gray(a); not working says
Undefined function or method 'rbg2gray' for input arguments of type 'uint8'

• June 5, 2019 at 3:32 pm

• June 5, 2019 at 3:32 pm

image mapping , very nice video thanks

• June 5, 2019 at 3:32 pm

Thank you for the video!

• June 5, 2019 at 3:32 pm

is there any ways to translate it into c++ code?

• June 5, 2019 at 3:32 pm

I'm so proud u have a Sorrento's picture..i'm from Naples!

• June 5, 2019 at 3:32 pm

hey thanku.. that was useful.
i am having trouble with "subplot(1,2,1),imhist(a_gray)" command
when i m entering it there is no output shown in my system..
please can u tell me y?

• June 5, 2019 at 3:32 pm

Try the "Facecrypt" series of image-processing challenges! Its awesome!

• June 5, 2019 at 3:32 pm

no offence but u have the voice of an angel, too husky and I can't really understand what are u talking about but anyway,useful video,thank you. (the 'almost' correct use of 'no offence')

• June 5, 2019 at 3:32 pm

you can see "Digital Image Processing USING MATLAB (Gonzalez).pdf"

• June 5, 2019 at 3:32 pm

pls, can u teel me what the name of this function ?

• June 5, 2019 at 3:32 pm

there is 🙂

• June 5, 2019 at 3:32 pm
• 