필터 지우기
필터 지우기

Average intensity of an image

조회 수: 10 (최근 30일)
Surendra Ratnu
Surendra Ratnu 2022년 11월 3일
댓글: KSSV 2022년 11월 3일
Hi, an image is in unit8 or greyscale image and data in I(x_i,y_j) format. How will calculate average intensity of an image without using any function and the expression of avg intensity is:

답변 (1개)

KSSV
KSSV 2022년 11월 3일
A = magic(5) ;
[m,n] = size(A) ;
iwant = 0 ;
for i = 1:m
for j = 1:n
iwant = iwant+A(i,j) ;
end
end
iwant = iwant/(m*n) ;
[iwant mean(A(:))]
ans = 1×2
13 13
  댓글 수: 4
DGM
DGM 2022년 11월 3일
If you're going to commit to doing things the hard way, you'll have to also commit to paying extra attention to variable class. If the image is an integer-class array (e.g. uint8), then the accumulated sum will also be implicitly uint8. It will immediately be truncated, so the sum will never exceed 255. In all probability, the product of the page geometry (i.e. m*n) will be much larger than 255, so the division step will round to a mean of 0, since that's the closest integer.
Make sure A is of an appropriate class.
A = double(A);
KSSV
KSSV 2022년 11월 3일
@Surendra Ratnu I have thought about this question while answering. I left it for you to figure out. Any ways you have the answer from @DGM

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

카테고리

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

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by