필터 지우기
필터 지우기

How to find mean gray level in gray scale image

조회 수: 9 (최근 30일)
Iqra Rizvi
Iqra Rizvi 2017년 3월 23일
댓글: Iqra Rizvi 2017년 3월 25일
I'm trying to find gray level of a gray scale image. I came through this in one of the questions you answered
X = imread(image);
imshow(X);
minGL = min(X(:));
maxGL = max(X(:));
meanGL = mean(X(:));
but its giving me same answer for every gray scale image i.e
  댓글 수: 3
Iqra Rizvi
Iqra Rizvi 2017년 3월 23일
i'm getting result meangraylevel .. because i've saved the matlab file with that name .. i'm not getting min , max n mean as the result
KSSV
KSSV 2017년 3월 24일
편집: KSSV 2017년 3월 24일
Clear the workspace using clear all and run the code.

댓글을 달려면 로그인하십시오.

답변 (2개)

Thorsten
Thorsten 2017년 3월 24일
If you write a script and call it 'meangraylevel.m', that script changes only the variables that you use in the script, but not a variable that has the same name as the script. You should write a function instead.

Image Analyst
Image Analyst 2017년 3월 24일
I don't know what you're running but you're not running meangraylevel.m. How do I know? Well, you don't have any semicolon after the lines where you compute minGL and maxGL yet those are not being echoed to the command window.
Next, you do have a semicolon after the line where you compute meanGL so that will not be echoed to the command window. So I'm not really sure how that meangraylevel number is getting output to the command window. Like I said, it should be minGL and maxGL and nothing else in the command window.
Next, it's not clear to use if you changed the filename each time you ran this. Are we to assume you did?
  댓글 수: 1
Iqra Rizvi
Iqra Rizvi 2017년 3월 25일
After putting the semicolon , I am not getting any answer

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by