How to calculate "CONTRAST PER PIXEL(CPP)" of an image

조회 수: 4 (최근 30일)
Tuhin  Sheikh
Tuhin Sheikh 2013년 7월 4일
댓글: shree san 2017년 10월 20일
To measure the quality of an image i'm using Contrast Per pixel(CPP).
It is defined as the average intensity difference between a pixel and its adjacent pixel.
I'm not used to with this metric. If anybody is well known with this metric, please share it.
Thanks

채택된 답변

Image Analyst
Image Analyst 2013년 7월 4일
Something like this perhaps (untested)
kernel = [-1, -1, -1, -1, 8, -1, -1, -1]/8;
diffImage = conv2(double(grayImage), kernel, 'same');
cpp = mean2(diffImage);
  댓글 수: 3
Image Analyst
Image Analyst 2013년 7월 4일
편집: Image Analyst 2013년 7월 4일
Conv2() is a sliding filter. I made a 3 by 3 window that basically takes the (center - upper left) + (center - top left) + (center - upper right) + (center - left) + (center - right) + (center - lower left) + (center - bottom left) + (center - lower right). That is the sum of all the differences between the center and the 8 surrounding pixels. Then I divide by 8 to get the average difference between a pixel and it's neighbors. The conv2() function just does that operation on every single pixel in the image as it slides that window along pixel-by-pixel and carries out those operations. Then we have an image where each pixel is the average difference between the original pixel at that location and the 8 neighbors. The mean2 simply gets the mean over all the pixels.
You would have to have a metric that models human perception. I'm not aware of any, but you might check here: http://en.wikipedia.org/wiki/Video_quality
Tuhin  Sheikh
Tuhin Sheikh 2013년 7월 7일
Thanks for the explanation and the suggestions sir

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

추가 답변 (1개)

shree san
shree san 2017년 10월 10일
Dear sir/Madam, Thank you so much for the above code. It helped me to calculate the contrast per pixel. But my output gives negative values. Is that right and how I can say the best contrast enhanced image from the output?
output I got is -58.3770 original image
-499.6260 contrast enhanced image
Looking for a favourable answer. Thank you
  댓글 수: 2
Image Analyst
Image Analyst 2017년 10월 12일
Yes, it is possible to get a negative Laplacian for some pixels. I don't know how you got your numbers. To get a nice contrast adjustment, try imadjust().
shree san
shree san 2017년 10월 20일
Thank you so much

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

Community Treasure Hunt

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

Start Hunting!

Translated by