how to obtain the gray level values of the image pixels??

I'm doing handwriting analysis,for that one feature is to identify the pressure.For the analysis of pen pressure, Mean gray level value is computed using the gray level values of the image pixels.But how to take these gray level values?? For reference i have attached the image.Please do help me.Thank you
if i use
meanIntensityValue = mean(grayImage(:));
is it that mean of both white and black pixels ? i want only mean of black pixels.

Answers (1)

You can get a mask of the letters using my attached demo.
Then do
meanGrayLevel = grayImage(mask);

9 Comments

You might also need to consider the width of the pen line. It might be narrower when the pressure is lighter.
i'm getting error in the attached demo sir.
??? Undefined function or method 'imgradient' for input arguments of type 'uint8'.
Error in ==> document_threshold at 75
sobelImage = imgradient(grayImage, 'Sobel');
this is the error.what changes should be made??
and how to consider width of the pen line?
imgradient is in the image processing toolbox since R2012b. Either you have an earlier MATLAB or you do not have that toolbox installed (or licensed.)
Yes sir,i have R2011a,ill collect the higher version,thanks for the info sir
Hello sir,i am now using R2013a,i executed your code(document_threshold.m),but now i'm not getting where to put
meanGrayLevel = grayImage(mask);
and what is mask here??(i mean which variable of your code should be substituted?) Please help me
mask in that line of code is called binaryImage in the document_threshold.m file.
You can put the line of code to compute the mean gray level wherever you need it, perhaps right after you compute the binary image mask.
Thank you sir.And very sorry for asking after a long gap! I am now calculating meanGrayLevel,but its not displaying anything in the terminal.How do i get the value?please help me

Sign in to comment.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Asked:

on 19 Dec 2015

Commented:

on 8 Jan 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!