필터 지우기
필터 지우기

Computing the integral of a binary image

조회 수: 4 (최근 30일)
Said Rahal
Said Rahal 2012년 7월 2일
Hello fellows:
I am trying to figure out how to compute the integral of the square of the difference between 2 images. So far I know that I have to convert the image to a binary one, but in order to compute the integral I am thinking of plotting the profile of the intensity values of each image than subtract one from another and integrate after I square the result. What do you think about that methodology? If it is wrong or you have a better one can you share keywords for the approach to do that?

채택된 답변

Walter Roberson
Walter Roberson 2012년 7월 2일
The integral of the square of the difference between two binary images is
sum(BinaryImage1(:) ~= BinaryImage2(:))
That is:
0 - 0 = 0; 0^2 = 0; and (0 ~= 0) = 0
0 - 1 = -1; (-1)^2 = 1; and (0 ~= 1) = 1
1 - 0 = 1; 1^2 = 1; and (1 ~= 0) = 1
1 - 1 = 0; 0^2 = 0; and (1 ~= 1) = 0
and thus the square of the difference is the same as ~= of the values.
  댓글 수: 2
Star Strider
Star Strider 2012년 7월 2일
Isn't that the same as 'xor'?
sum(xor(A,B))
Sean de Wolski
Sean de Wolski 2012년 7월 2일
@Star Strider: yup:
xor([1 1 0 0],[0 1 1 0])
ne([1 1 0 0],[0 1 1 0])

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

추가 답변 (1개)

Image Analyst
Image Analyst 2012년 7월 2일
Sounds like you just want the RMS difference between the two images, so I guess I don't understand why you think you must convert the images to binary images, or why " plotting the profile" is necessary. For gray scale images, why not just do
rmsDifference = sqrt(sum((double(grayImage1(:)) - double(grayImage2(:))) .^2));

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by